0
votes

In the root, I have 2 buttons that when you press the first one, it goes to the first frame inside the movieclip, if I press the second button it goes to the second frame.

I have the following function in frame 2 inside a movieclip.

function loadMap(mapBoolean:Boolean):void{
    if(mapBoolean == false){
        var loader:Loader = new Loader();
        loader.load(new URLRequest("1.png"));
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
        function loadComplete(e:Event){
            map_holder.addChild(loader);
            MovieClip(root).mapLoaded = true;
        }
    }
}

Var declared: var mapLoaded:Boolean = false;

Button #2 function:loadMap(mapLoaded);

When I first press button #2 it goes to the second frame in the movieclip, it successfully loads the image into the holder. Then I press button #1 to return to the first frame and press button #2 to go to the second frame, and the image is gone. Why is this happening?

1
does map_holder exist in the first frame? - Boris
When I place the holder in the first frame. It works. But when I place a mask over it, so that it only displays in the 2nd frame, it does not work again. It is weird. - Anderson

1 Answers

0
votes

two options :

  • either you put the holder on frame 1 (and set its alpha to 0 or visible to false)
  • or you keep your loader in a variable, declared the same way as mapBoolean:

code frame 1

var loader:Loader;

code frame 2

if(!loader){
  loader = new Loader();
  loader.load(new URLRequest("1.png"));
  //no need for event listening
}
map_holder.addChild(loader);