>  I saw some posts on this topic and didn't see any solution to this yet.
>
>  Is there a way to use Actionscript 3.0 in Flex/AIR to generate .SWF at
>  runtime? I guess I can't call the mxml/as compiler directly.

They were probably my posts on the topic... I was looking to
accomplish the same thing. There's no official way to do this, i.e.
you can't create MovieClip objects using any AS3 API. The only route
would be to generate the SWF byte code by hand in a ByteArray then
load from that (similar to what some of the mixing audio libraries
do). It'd be awesome if Adobe officially provided API for this...
ahem!

There's also no straightforward way to do this offline, i.e. generate
a SWF from a folder full of PNGs. You can do this manually in the
Flash IDE; and it appears as if there is some way to do this using the
MXML compiler by chaining loading frames, but I wasn't able to work
out how to do it.

My solution ended up being this: I created a PHP script that scanned a
folder for PNGs and generated an AS class containing all of the images
as embeds. The class implemented an interface that allowed the images
to be queried, listed, etc. I then compiled that class to a SWF I'd
load at runtime.

Nothing clever, just brute force code generation. I am kind of
disappointed that Adobe hasn't created any "toolchain" for assets to
go along with Flex, everyone seems to be rolling their own. It would
be dead simple for them (with their knowledge of SWF bytecode
internals) to create a command-line tool that transformed a directory
full of images and sounds into a SWF library. I get the vibe that
compc (the component compiler, SWC's) kinda does this, but I don't
quite understand if those SWC's can be used at runtime or if they're
like LIB files and only usable as compilation units.

I'd love to spend a few weeks building some of these tools as I don't
think they'd be any kind of rocket science. I'd love to see a SWF
bytecode API (in AS3) that can generate assets (code would be a
bonus), and an offline toolset that can do the same. Swfmill basically
did this (for offline), but it hasn't been updated to Flash9/AS2 (last
I checked).

Troy.

Reply via email to