Actionscript 3 停止即时复制不';不要为简单按钮工作
我正在尝试取消此actionscript3代码中的事件:Actionscript 3 停止即时复制不';不要为简单按钮工作,actionscript-3,mouseevent,simplebutton,Actionscript 3,Mouseevent,Simplebutton,我正在尝试取消此actionscript3代码中的事件: public class Main extends Sprite { public function Main() { this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } protected function onAddedToStage(event:Event):void { this.a
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
}
}
如何取消事件并将鼠标悬停在按钮上?
在本例中,当您悬停时按钮会响应 您的悬停事件似乎是添加在主屏幕上,而不是按钮上。 尝试将事件侦听器放在您声明的btn上
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);
btn.addEventListener(MouseEvent.MOUSE_OVER, onOver, true, int.MAX_VALUE);
}
我正在努力防止过度夸大。滚动也没有结果我不确定
SimpleButton
如何在内部处理其状态,但通常如果不想更改状态,他们会将其启用属性设置为false
。您也可以手动更改状态(例如btn.overState=btn.upState
)不可能获得所有可能的活动按钮