开发者

How to export MovieClip to SWF via AS3?

开发者 https://www.devze.com 2023-01-25 11:52 出处:网络
I\'ve wrote some application in Flash cs5, wich allow u开发者_运维技巧sers to make their own Christmas Cards, but at the end of programming I realized, that I should to provide some function to save u

I've wrote some application in Flash cs5, wich allow u开发者_运维技巧sers to make their own Christmas Cards, but at the end of programming I realized, that I should to provide some function to save user's card to seperate SWF-file...

Please, anyone who knows, help me! I tried to find something in Google, but all what I understand is that I should use ByteArray. But I can't really get, HOW I can use it in my case?

All I have found is this four lines:

var buffer:ByteArray = new ByteArray();

buffer.writeObject(MOVIE_CLIP_HERE);

buffer.position = 0;

buffer.writeBytes(...);

For seniors maybe it can help, but I can't get how with help of this lines I can solve my problem... thank you very much)))


You will need some server-side technology, like PHP or ASP, because Flash Player can't save anything on disk. And if you think about creating a swf file programmatically, that can be very difficult. That being said, this is how I would do this:

First, I would write the movieclip to a ByteArray, just like in your example:

var buffer:ByteArray = new ByteArray();
buffer.writeObject(card_mc);

Then I would send the byte array to a PHP script which would save the data from the byte array in a file (a text file will do). The saved data will actually be your serialized movieclip. Then, I would create a swf file which will serve as the actual card, but it will be in fact a container for the saved movieclip. This file will load the data from the text file into a ByteArray and deserialize the movieclip:

var loadedClip:MovieClip = MovieClip(byteArray.readObject());

Once you have managed this, you're done. When users save their cards to their computer, you can send them the container swf file and keep the data file on your server (but in this case the swf will need to load the movieclip from your server), or you can give them both files.

I hope this helped.

0

精彩评论

暂无评论...
验证码 换一张
取 消