Reputation: 11502
As I am building a Flex framework for minigames, I plan to bundle a bunch of graphic assets (movieclip symbols) into a single swf file, which I will load into my Flex application, before extracting the symbols from the swf file for use in my application. My question is this: how do I do this through actionscript?
Thanks!
Upvotes: 1
Views: 2444
Reputation: 1620
If you don't want to use EMBED and you don't want to load the assets on runtime I recommend you exporting the swf as an SWC.
This way, you can browse SWC files from actionscript. You can event check on compile time that a sub-movieclip inside another movieclip exists.
If you are using flex compiler then remember adding this when you compile:
-library-path C:\path\to\your\file.swc
If you're using FDT you have an option to auto add the SWC as arguments.
Here's a demo on how to do it with FDT. Not sure which tool are you using. If it's the commercial Flex Builder the process should be similar.
I think that's what you're looking for.
Upvotes: 1
Reputation: 5495
Lot's of good solutions here, here's one for if you are loading the swf at runtime and want to extract assets, you can do the following in your loader complete event listener:
var c:Class = Class(LoaderInfo(e.target).applicationDomain.getDefinition("myClassDefinitionName"));
This will store the asset from the swf as a Class object so you can create instances of it like so:
var asset:MovieClip = new c();
Upvotes: 0
Reputation: 1065
I'd try to create an asset/icon library AS file.
something along the lines of
package
{
public class IconLibrary
{
/*
* Framework Icons
*/
[Embed (source="../assets/fof_graphics.swf", symbol="clapperboard_icon")]
public static const clapperBoardIcon:Class;
[Embed (source="../assets/fof_graphics.swf", symbol="clapperboard_over_icon")]
public static const clapperBoardOverIcon:Class;
[Embed (source="../assets/fof_graphics.swf", symbol="close_button")]
public static const closeButton:Class;
[Embed (source="../assets/fof_graphics.swf", symbol="close_over")]
public static const closeOverButton:Class;
public function IconLibrary()
{
}
}
}
Then all you need to do is
source="{IconLibrary.clapperBoardIcon}"
or whatever the name of the asset you wish to show.
Upvotes: 0