我正在尝试取消此 actionscript3 代码中的事件:
public class Main extends Sprite
{
public function Main()
{
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onAddedToStage(event:Event):void
{
this.addEventListener(MouseEvent.MOUSE_OVER, onOver, true, int.MAX_VALUE);
var btn:SimpleButton = new SimpleButton(
createBtnState(0x0000FF),
createBtnState(0x00FFFF),
createBtnState(0x00FF00),
createBtnState(0x0000FF));
btn.x = stage.stageWidth - btn.width >> 1;
btn.y = stage.stageHeight - btn.height >> 1;
addChild(btn);
}
private function createBtnState(color:uint):Sprite
{
var s:Sprite = new Sprite();
s.graphics.beginFill(color, 1);
s.graphics.drawRect(0,0,100,20);
s.graphics.endFill();
return s;
}
protected function onOver(event:MouseEvent):void
{
event.stopImmediatePropagation(); //Don't work
}
}
如何取消事件悬停按钮?在此示例中,按钮会在您悬停时做出响应。