If one uses [Embed] to refer to external graphic assets its easy to instantiate and use them.
However, I've got a png in an Fla, with the Class identifier set to "Symbols", Base class is BitmapData.
I need to instantiate it like this:
var symbols:BitmapData = new Symbols(1, 1);
addChild(new Bitmap(symbols));
Of course the compiler complains about a call to a possibly undefined method Symbols.
For a temporary fix I guess i'll put the graphic external to the swf, but for this project it needs to be in the library along with everything else.
Well, the 1,1 is a red herring, just to ensure the new BitmapData instance is created with some dimensions (it gets the correct dimension from the bitmap)
The problem here is the disconnect between the class identifier in the library of a swf created in Flash.exe, and compiling it using an external compiler. If I followed your suggestion - var symbols:Symbols = new Symbols(); - the compiler would still complain about an unkown identifier.
Can't use Flash to compile, we use Maven/Flex-mojos. Why do it the simple way when you can hugely overcomplicate it?! Compilation has to be done in a DOS window and just to do a few classes takes a couple of minutes as all manner of Java malarkey takes place also. Our enterprise imposes a load of restrictions on how you can create code assets.
Yep, it is in a separate swf, but that wouldn't affect compilation. After a bit of checking around, I've created a Symbols class (as opposed to allowing Flash to create a default class when exporting the swf) that subclasses BitmapData and just contains a constructor. This allows a clean compile using the flexcompiler. Havent actually got it displaying yet but its a step in the right direction....
North America
Europe, Middle East and Africa
Asia Pacific