jeudi 29 décembre 2016

load multiple external SWF's to unknown number of movieclips and control them (AS3)

I'm creating a multi-player game that every user can join it. I want to load some assets to every user who going to join, but to be able to control them when user is doing some actions. For example, if the user is going forward, the asset will gotoAndStop at frame number 2.

I know that I can load SWF and control them by creating a variable of movieclip (myLoader.data); but I can't create unknown num of variables.

I have tried to do something like this:

var asset:MovieClip;
var myLoader:Loader = new Loader;
myLoader.load(new URLRequest("Asset_1.swf"));
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE , onCom);
function onCom(e:Event):void{
    asset = MovieClip(e.target.content.HOV_1);
    myUser.assetsCont.addChild(asset);
}

but when I'm doing this:

myUser.assetsCont.asset.gotoAndStop(2);

It's giving me an error. What can I do?

Aucun commentaire:

Enregistrer un commentaire