AS3 to Generate Dynamic SWF?

2019-02-21 04:12发布

问题:

Is it possible, using AS3, to programmatically generate a .swf file? What my little app does is load a bunch of images, using FileReference, now I want to compile them into a stand-alone swf that the user can download (the swf will be a slideshow).

[edit]

There seems to be some mis-understanding of what I am asking. I want to have one compiled swf from which the user may select some images and press a button whereby the swf will create and compile a second swf containing said images. As this is a stand-alone app, there will be no server-side interaction.

What I am thinking is that there will be a string representing a dynamic class. When the user selects their images the appropriate embed tags are added to this string, which is then compiled and saved to the user's desktop.

So my question is, can a compiled swf generate and compile a second swf?

回答1:

Take a look at this library, this allows you to create a .swf at runtime. https://github.com/claus/as3swf



回答2:

It should be possible to do server side, by generating the relevant code and running the as3 compiler.



回答3:

I haven't investigated the package thoroughly, but the As3Eval library seems to be doing what you're asking - realtime compilation of AS3 into executable bytecode (on the client with no server interaction). Check out the demo.

I'm not sure it would support image embedding - perhaps you could encode the image data as a base64 string in your dynamically built source code.



回答4:

You could also use swfmill, a command-line tool to create SWF files from XML documents.

It's not well documented but for basic usages (such as creating asset libraries) you should find what you need.