Skip to main content
Participating Frequently
April 25, 2013
Answered

loading movie clip to stage with button click AS3

  • April 25, 2013
  • 1 reply
  • 7584 views

I'm trying to figure out how to load a movie clip to the stage with a button click and have the movieclip close again using a close button. Does anyone have a step by step on how to do this or links to some tutorials.

Below is an example of what I'm trying to do.

http://i30.photobucket.com/albums/c316/good_snow/FlashBoxSample_zps4e655414.jpg

This topic has been closed for replies.
Correct answer kglad


looks like you're using an "el" and a "one".  they look similar but they're not the same.

copy and paste from your code to your properties panel or vice-versa to correct.

1 reply

kglad
Community Expert
Community Expert
April 25, 2013

where's the movieclip?

if it's in your library, assign a class (eg, MC) and use the "new" constructor:

var mc:MC

add_btn.addEventListener(MouseEvent.CLICK,addF);

close_btn.addEventListener(MouseEvent.CLICK,closeF);

function addF(e:MouseEvent):void{

mc=new MC();

addChild(mc);

}

function closeF(e:MouseEvent):void{

removeChild(mc);

mc=null;

}

kglad
Community Expert
Community Expert
April 26, 2013

use:

var popup1:Popup1

add_btn.addEventListener(MouseEvent.CLICK,addF);

close_btn.addEventListener(MouseEvent.CLICK,closeF);

function addF(e:MouseEvent):void{

popup1=new Popup1();

addChild(popup1);

}

function closeF(e:MouseEvent):void{

removeChild(popup1);

popup1=null;

}

subaru82Author
Participating Frequently
April 26, 2013

So I put that code on my button and it doesn't do anything?