ArdentKid Posted June 10, 2012 Share Posted June 10, 2012 I'm using LoaderMax, and can't seem to figure out how to create a new instance of a movieclip it loads. I am loading an external SWF with a mc in the library. I'm new-ish to as3 so please be gentle. I think without LoaderMax, I would want to load the swf, and then do something like: var ObjectdAsset:Class = applicationDomain.getDefinition('mc_name'); var instance1 = new ObjectAsset(); var instance2 = new ObjectAsset(); ...etc Much appreciated Link to comment Share on other sites More sharing options...
Carl Posted June 10, 2012 Share Posted June 10, 2012 Hi, and welcome to the forums. Yes, you can use SWFLoader's getClass() method to do exactly what you want. import com.greensock.loading.*; import com.greensock.events.LoaderEvent; var assetsSWF:SWFLoader = new SWFLoader("externalAssets.swf", {onComplete:completeHandler}); function completeHandler(e:LoaderEvent):void{ trace("loading complete"); //ceate a reference to the Circle Class in the external swf var circle:Class = e.target.getClass("Circle"); trace(circle); //create an instance of the Circle class and add to stage var myNewCircle:MovieClip = new circle(); addChild(myNewCircle) } assetsSWF.load(); externalAssets.swf has a symbol in the Library with class of "Circle". I have uploaded a zip containing CS4 fla files. useAssetsFromExternalSwfLibrary.zip Link to comment Share on other sites More sharing options...
ArdentKid Posted June 10, 2012 Author Share Posted June 10, 2012 Thanks, that's exactly what I needed! Now I'm looking into manipulating the asset... Say I have a character_head_mc and I want to add to all instances a child accessory_hat. Do I need to keep track and iterate over all references of the head or can I somehow tell the class to now make the hat it's child? In flash I could do this by dragging a hat movieclip from the library into the head movieclip. Link to comment Share on other sites More sharing options...
Carl Posted June 11, 2012 Share Posted June 11, 2012 I'm pretty sure you are going to have to iterate through all the instances of your heads and add the hats. Link to comment Share on other sites More sharing options...
ArdentKid Posted June 11, 2012 Author Share Posted June 11, 2012 Ah, that's what I thought. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now