简体   繁体   中英

Load mc's on button presses and check if mc's are running

I'd like to load and onload mc's on the stage when certain buttons are pressed.

The catch is that whilst one of the mc's is playing I dont want any of the buttons to work -- in other words the user has to wait for the short anim to stop playing before they press another button to see another anim (or even the same anim again).

I'm OK with basics of AS2, but I want to do this in AS3.
Is attachMovie and removeMovieClip still the approp method to load/unload mc's from library in AS3.
I'm also unsure how to check if mc is playing in AS3 (is there a property? or maybe set a global variable?).

Any ideas??

you want something like:

myBtn.addEventListener(MouseEvent.CLICK,onMyBtnClick)

function onMyBtnClick(e:MouseEvent)
{
   //TODO disable buttons

   //export for actionscript setting in library
   var myMovie:SomeMovieClipFromLibrary = new SomeMovieClipFromLibrary(); 
   addChild(myMovie);
   myMovie.addEventListener(Event.ENTER_FRAME,onMovieEnterFrame);
   myMovie.play();

}

function onMovieEnterFrame(e:Event)
{
  if(e.currentTarget.currentFrame ==e.currentTarget.totalFrames)
  {
    //TODO enable buttons
    e.currentTarget.removeEventListener(Event.ENTER_FRAME,onMovieEnterFrame);
    removeChild(e.currentTarget as DisplayObject);

  }

}

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