如何通过AS3将MovieClip导出为SWF?
我在 Flash cs5 中编写了一些应用程序,允许用户制作自己的圣诞贺卡,但在编程结束时我意识到,我应该提供一些功能来将用户的卡片保存到单独的 SWF 文件中...
拜托,谁知道,帮帮我吧!我试图在 Google 中找到一些东西,但我所理解的是我应该使用 ByteArray。但我真的不明白,我如何在我的情况下使用它?
我发现的只是这四行:
var buffer:ByteArray = new ByteArray();
buffer.writeObject(MOVIE_CLIP_HERE);
buffer.position = 0;
buffer.writeBytes(...);
对于老年人来说也许它可以提供帮助,但我不知道如何在这条线的帮助下解决我的问题......非常感谢)))
I've wrote some application in Flash cs5, wich allow users 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)))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要一些服务器端技术,例如 PHP 或 ASP,因为 Flash Player 无法在磁盘上保存任何内容。如果您考虑以编程方式创建 swf 文件,那可能会非常困难。话虽这么说,这就是我要做的:
首先,我将电影剪辑写入 ByteArray,就像在您的示例中一样:
然后我将字节数组发送到 PHP 脚本,该脚本会将字节数组中的数据保存在一个文件(文本文件即可)。保存的数据实际上是您的序列化影片剪辑。
然后,我将创建一个 swf 文件,它将用作实际的卡,但它实际上是保存的影片剪辑的容器。该文件会将文本文件中的数据加载到 ByteArray 中并反序列化影片剪辑:
管理完此操作后,您就完成了。当用户将卡片保存到计算机时,您可以向他们发送容器 swf 文件并将数据文件保留在您的服务器上(但在这种情况下,swf 需要从您的服务器加载影片剪辑),或者您可以向他们提供这两个文件。
我希望这有帮助。
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:
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:
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.