Skip to main content
January 26, 2014
Answered

How to load an object from library by clicking on a button?

  • January 26, 2014
  • 1 reply
  • 493 views

How can we load and unload an object ( like a picture ) from our library by just clicking on a button and then unload it by clicking on an other button using as2.

Thanks for the help

This topic has been closed for replies.
Correct answer kglad

assign the button an instance name (eg, btn) and assign the library object a linkage id - right click the library symbol>click properties>tick export for actionscript>assign a linkage id (eg, mc_id) and click ok.  then use:

var tl:MovieClip=this;

btn.onRelease=function(){

tl.attachMovie("mc_id","mc",tl.getNextHighestDepth());

}

// to remove, mc.removeMovieClip();

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 26, 2014

assign the button an instance name (eg, btn) and assign the library object a linkage id - right click the library symbol>click properties>tick export for actionscript>assign a linkage id (eg, mc_id) and click ok.  then use:

var tl:MovieClip=this;

btn.onRelease=function(){

tl.attachMovie("mc_id","mc",tl.getNextHighestDepth());

}

// to remove, mc.removeMovieClip();