David Salzer
David Salzer

Reputation: 872

AS3: Export a MovieClip or Canvas to swf

I'm having an app where the user can edit a simple greeting card and should be able to send it to another user. We are currently doing it by exporting to a graphic file and sending with some server script.

Now - we found a need to export that card to swf. This card is basically a (Flex) Canvas holding some images and labels.

What do you say? Can that be done? Any help will be appreciated.

Thanks!

Upvotes: 3

Views: 2751

Answers (2)

Fire Crow
Fire Crow

Reputation: 7729

server side flex sdk compiles actionscript or flex from the command line on any linux/unix/windows machine

I use the flex command line compiler to develop flash apps from my linux desktop, will work great on a server and is scriptable from your web app.

here are the steps

1.) download the flex sdk from adobe, and unzip it on the server

2.) generate the actionscript *.as file or flex *.mxml file for the card

3.) run this in a linux shell on the server to generate the SWF

SOURCE_FILE=/dir/with/flex_sdk/

OPTS='-use-network=false'
# note this is a relative path to the flex sdk
CONFIG_FILE='flex-config.xml'

if [ -f $CONFIG_FILE ]; then
    OPTS=$OPTS' -load-config='$CONFIG_FILE
fi

OPTS=$OPTS' -output /path/to/ouput/swf'

/path/to/flex_sdk/bin/mxmlc $OPTS $SOURCE_FILE

the sdk works on windows also but I'm not sure what the command line arguments are

Upvotes: 1

LiraNuna
LiraNuna

Reputation: 67261

Deep copy the MovieClip object to a ByteArray and dump it to a file.

var buffer:ByteArray = new ByteArray();
buffer.writeObject(MOVIE_CLIP_HERE);
buffer.position = 0;
buffer.writeBytes(...);

Upvotes: 5

Related Questions