0
votes

I want to create a flip effect button, on click event of which a external swf should be opened removing all the contents of current swf. I have created both components, a button and also a movieclip. Neither of its load ( new URLRequest()) code working. Below is the complete code I am using. Where btn2 is class name of my movie clip and 2.swf is external swf I want to load.

stop();
var bc2:btn2 = new btn2();
bc2.buttonMode = true;
bc1.addEventListener(MouseEvent.CLICK, mouseClick);

var loader = new Loader();

function mouseClick(event:MouseEvent): void {
     loader.unload();
     loader.load(new URLRequest("2.swf"));
     addChild(loader);
}
1

1 Answers

0
votes

First btn2 instance what you are instantiating needs to be added for it to be visible.

Secondly you are trying to load the swf even before its loaded.

I have modified the code

stop();
var bc2:btn2 = new btn2();
bc2.buttonMode = true;
this.addChild(bc2);
bc2.addEventListener(MouseEvent.CLICK, mouseClick);

var loader = new Loader();

function mouseClick(event:MouseEvent): void {
     loader.unload();
     loader.load(new URLRequest("2.swf"));
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
}

function completeHandler(event:Event):void{
    this.addChild(loader);
}

This should work...