We’ve had a situation here. It’s irritating. It’s annoying. It happens over and over. It is as follows:
- SWF A wants to load SWF B.
- SWF B has a linked MovieClip in the library. This is a simple extension of MovieClip, nothing fancy. Let’s call it Foo.
- SWF A wants to call new Foo(); and add it to the stage.
- Compiler hates us.
Daniel, Josh and I sat together and had a pow-wow and came up with this:
import flash.utils.getDefinitionByName;
function getAsset($str:String):MovieClip
{
var c:Class = Class(getDefinitionByName($str));
return new c();
};
(Amazingly, it worked out so that I typed lines 1 and 2, Daniel typed lines 3 4 and and Josh lines 5 and 6. Therefore, we all share joint credit in this astounding revelation.)
This function will comb for a class by string, assume it’s a MovieClip and return it. Now we just agreed on a simple convention: All linked movieclips will begin with “lib.”.
So I can easily write:
var myFoo:MovieClip = getAsset("lib.Foo");
addChild(myFoo);
from SWF A once SWF B is loaded. Presto!
Daniel is going to build this into a nice, pretty utility class. When he does, rest assured that we’ll distribute it here.
November 30th, 2007
by Stephen
/ Comment
I used Flexbuilder for a couple of big AS3 and Flex projects and once you start to develop in Flexbuilder (Eclipse) you maybe don’t wanna go back and use a normal Text Editor. So i was looking for a way to use Flexbuilder for heavy graphical sites that also need the Flash 9 IDE.
I think the best way to work on big projects is for designers to work in the Flash IDE and for Developers to add functionality with a professional programming tool like Flexbuilder.
I was playing around with swc’s but it just didn’t work the way a wanted it to work.
Josh came up with the idea of loading swf-files and accessing the assets through the swf, not through a swc. I tested it the way I like it to use in Flexbuilder and it works perfectly (ie. code completion and code checking still works). You can add all functionality after you compile the asset-swf. This is the perfect way to work hand in hand with designers.
So here are the basic steps: Read More »
November 9th, 2007
by Stephen
/ Comment
A lot of the time, the only reason I have Flash open is to compile an fla which is completely empty except for the document class.
I have been playing with the mxmlc compiler and TextMate Bundles in an effort to create a workflow where I can create a project and compile an AS3 class into a swf straight from TextMate without Flash or FlexBuilder open. I started with the various build commands in the current Actionscript 3 Bundle and edited it so I could specify which class would be compiled and the name and location of the resulting swf. I am also working on commands for testing in adl (AIR debugger) and eventually I plan on creating a command to package AIR apps.
I will post all of it here as soon as it is post-worthy, so check back soon.
November 7th, 2007
by Stephen
/ Comment