更新:这不是一个实际问题。事实证明,正在创建另一个 Sprite 并将其设置为 alpha=0,它恰好位于与 SimpleButton 高度相同的 Y 位置。这阻止了与按钮的交互。谢谢你们的想法。我正在结束这个问题。
我有一个 SimpleButton,我将其放置在舞台上。当我将它设置为 Y 位置时,我正在用它做各种事情,它会破坏/改变 hitArea。
var playUp:Bitmap = getBitmap('play_up');
var playDown:Bitmap = getBitmap('play_down');
var Y:Number = 100;
_playButton = new SimpleButton(playDown, playUp, playDown, playDown);
_playButton.addEventListener(MouseEvent.CLICK, playClick);
_playButton.x = (640 / 2) - (_playButton.width / 2);
_playButton.y = Y;
_playButton.name = "playButton";
var shadow:DropShadowFilter = new DropShadowFilter();
shadow.distance = 5;
shadow.angle = 25;
shadow.alpha = 0.5;
shadow.blurX = 8;
shadow.blurY = 8;
_playButton.filters = [shadow];
addChild(_playButton);
如果我删除该_playButton.y = Y;
按钮工作正常的行,它的命中区域会覆盖整个按钮。
如果我设置var Y:Number = playDown.height;
了,那么我根本无法翻转或单击按钮。
如果我设置var Y:Number = playDown.height - 10;
然后只有按钮的顶部 10px 处于活动状态,我可以单击并翻转顶部 10px。
我尝试将按钮包装在另一个 Sprite 中并移动包含的 sprite,但它会导致完全相同的行为。
var playUp:Bitmap = getBitmap('play_up');
var playDown:Bitmap = getBitmap('play_down');
var Y:Number = 100;
_playButton = new SimpleButton(playDown, playUp, playDown, playDown);
_playButton.addEventListener(MouseEvent.CLICK, playClick);
_playButton.x = (640 / 2) - (_playButton.width / 2);
_playButton.y = Y;
_playButton.name = "playButton";
var shadow:DropShadowFilter = new DropShadowFilter();
shadow.distance = 5;
shadow.angle = 25;
shadow.alpha = 0.5;
shadow.blurX = 8;
shadow.blurY = 8;
_playButton.filters = [shadow];
var holder:Sprite = new Sprite();
holder.addChild(_playButton);
addChild(holder);