解决SimpleButton被移除后保持OVER状态

假设场景中有一SimpleButton叫testBtn,执行下面操作:
     1.鼠标移上testBtn, testBtn状态变为OVER
     2.移除testBtn,removeChild(testBtn)
     3.5秒后重新添加testBtn到场景
 
此时,看见testBtn还是OVER状态。
 
 
解决方法:
 
1.记录testBtn的UP状态
 
     private var _upState:DisplayObject = testBtn.overState;
 
2.testBtn被移除时,更改其状态
 
     testBtn.overState = testBtn.upState;
 
3.testBtn被加载在场景时,添加事件监听
 
  testBtn.addEventListener(MouseEvent.ROLL_OVER,function(event:MouseEvent):void{
     testBtn.overState=_overState;
     testBtn.removeEventListener(event.type, arguments.callee);
});
原文地址:https://www.cnblogs.com/in1ts/p/4252737.html