Wednesday 14 March 2012

More on Flex

Just a short update, but it's on an important point as I discovered something to make my life a whole lot easier.


I had read that Flex's Embed syntax could be used in projects built using Flash CS, but the documentation was unclear on how to do this. There's nothing in the Flash CS documentation, while many Flex examples assume you're using only Flex (and a lot of XML and Flex components) or are using FlashDevelop to build apps (not available to me on a Mac).


So after getting my app building with Flex, using Embed,  as described here and here, I was also maintaining code that loaded assets from the Library of a .fla file, as well as maintaining that file. This was fiddly but not too much work as I have hardly any art assets at the moment.


Today I wanted to do some debugging to track down a problem, so switched the code to load art from the .fla file, and disabled the shader, and tried building. Except I'd forgotten about the font I'd added using Flex so did not remove that Embed code.


Then when I hit build it noticed and put up a dialog asking for the path of the flex SDK. I supplied it, hit build again, and it built and ran. I changed the graphics code so it too loaded assets using Embed and it also built and ran. All I needed to do, to get it to use the Flex compiler within Flash CS, is to try and build code with Flex-specific extensions. This is a seemingly undocumented feature of Flash CS (version 5.5) but a very welcome one.


This makes everything much easier, as I only need to maintain one code base when developing and debugging. I may still need Flash to do a pre-loader but I can do that by wrapping the main game in a container .swf which takes care of loading everything in order using the timeline.

No comments:

Post a Comment