简体   繁体   中英

As2 loading swf instance

I have a .swf which loads an external .swf:

this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
var my_listener:Object = new Object();

my_listener.onLoadComplete = function(target_mc:MovieClip) {
target_mc._x = 50;
target_mc._y = 50;
addChild(my_loader);

        var blocker = my_loader.content.test
        blocker._visible = false;
}

my_listener.onLoadProgress = function(target_mc:MovieClip) {
trace(target_mc.getBytesLoaded() + " out of " + target_mc.getBytesTotal());
}

var my_loader:MovieClipLoader = new MovieClipLoader();
my_loader.addListener(my_listener);
my_loader.loadClip("child_as2.swf", container_mc);

I want to acces the external swf and make the movieclip with instance name test visible = false; but it won't work.

I have tried a lot of codes and right now it throws me this error:

Scene=Escena 1, layer=Capa 1, frame=1, Line 9 There is no property with the name 'content'.

Any idea?

If you have a better code i will thank you so much.

First of all, it looks like you're mixing AS2 and AS3. AS2 doesn't have addChild method and whatever you're loading gets added once loaded. If you want to activate your external movieclips only later, I recommend to make them so that their root only has 2 frames first of which is blank and everything is on second one. Then, in onLoadInit you tell it to gotoAndStop(1). Here's some sample code:

var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener({
    onLoadInit: function(mc:MovieClip):Void {
        mc.gotoAndStop(1);
    }
});

var container:MovieClip _root.createEmptyMovieClip('mc_container', _root.getNextHighestDepth());
loader.loadClip('clip.swf', container);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM