mirswith
mirswith

Reputation: 1345

how to access class from embedded swf

I am trying to get an instance of a specific class from an embedded swf, it so happens the class I need is also the Default Application extending Sprite for the swf. I am able to do this successfully if I load the swf however I want to embed it instead.

The class I want to load is also extending a custom interface. Here is what I have tried but is not working:

[Embed(source="resources/MySwf.swf")]
private var MySwf:Class;

private function someFunction() : void
{
    var inst:ISomeInterface = new MySwf() as ISomeInterface;
}

I appreciate any pointers.

Thanks.

Upvotes: 0

Views: 1440

Answers (1)

meddlingwithfire
meddlingwithfire

Reputation: 1437

Docs for embedding are here: http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html

You should be able to do something like:

[Embed(source='resources/MySwf.swf', symbol='TheExportNameInMyFlaLibrary')]
public var MySwf:Class;

Personally, I prefer to use the Flash IDE publish settings to be have Export as SWC checked. That way, you can just drop the SWC into your FlashBuilder projects' lib folder and be done. Don't have to worry about manually setting each class up like this.

Upvotes: 1

Related Questions