AS3单独放置一段时间后,使Movieclip消失

时间:2014-02-04 10:52:04

标签: actionscript-3 flash movieclip alpha-transparency enterframeevent

原始编辑 我想知道在舞台上制作movieClip淡出方式的最佳方法。我可以猜测如何在as2中做到这一点(这就是我所教的内容),但我不确定如何在下面开发我的代码。作为猜测我会假设将它附加到enterFrame事件。

基本上,如果用户没有与气球进行交互,则在5秒的过程中,使用alpha会逐渐消失。

任何指针或建议?我是AS3的新手。 (请忽略点击)

reset_balloon.addEventListener(MouseEvent.CLICK, fadeBalloon);
 function fadeBalloon(event:MouseEvent):void 
 { 
    reset_balloon.alpha = .2; 
 } 

辅助编辑-----

//---- 
//Resetter btn ---------------------
//------------------------------------------

reset_btn.addEventListener(MouseEvent.CLICK, startover);

 function startover(event:MouseEvent):void
  {
   //gotoAndPlay(2);
   reset_balloon.visible = true;
  }

  //---- 
Object(root).reset_balloon.thereseter_btn.addEventListener(MouseEvent.CLICK, truestartover);

  function truestartover(event:MouseEvent):void
  {
     gotoAndPlay(2);
   //reset_balloon.visible = false;
  }


  TweenLite.delayedCall(5, handleTimeUp)

   function handleTimeUp():void
   {
    TweenLite.to(reset_balloon, 2, {alpha:0});
   }

   reset_balloon.addEventListener(MouseEvent.CLICK, fadeBalloon);

    function fadeBalloon(event:MouseEvent):void 
     { 
     //reset_balloon.alpha = .5; 
  TweenLite.killDelayedCallsTo(handleTimeUp);
  TweenLite.to(reset_balloon, 2, {alpha:0.4});
    }

1 个答案:

答案 0 :(得分:0)

如果您不介意使用Tweens,我建议您使用TweenLite。

//Add function called in 5 secs
TweenLite.delayedCall(5, handleTimeUp)

private function handleTimeUp():void
{
    TweenLite.to(reset_balloon, 2, {alpha:0});
}

如果由于某种原因你要杀死待处理的延迟呼叫(例如在鼠标点击时);

reset_balloon.addEventListener(MouseEvent.CLICK, fadeBalloon);
private function fadeBalloon(event:MouseEvent):void
{
    TweenLite.killDelayedCallsTo(handleTimeUp);
}