我没有任何成功,让背景在鼠标悬停时显示为 0.5 alpha,Sprite 作为 TextArea 的父级。我能得到的最好的结果是在 MouseOver 上以 0.5 透明度出现的文本,这完全不是我想要的。无论鼠标状态如何,我都希望文本处于最大 alpha 值,并且只有背景(Sprite)在 MouseOver 上以半透明度显示。如果可能的话,我宁愿避免补间。这是我的代码:
var textSprite:Sprite = new Sprite();
public function Main()
{
textSprite.graphics.beginFill(0x000000, 0);
textSprite.graphics.drawRect(94.95, 80.95, 390, 130);
textSprite.graphics.endFill();
textSprite.addChild(picArea1);//textarea added on stage, same dimensions, transparent background
textSprite.buttonMode = true;
textSprite.useHandCursor = true;
stage.addChild(textSprite);
textSprite.addEventListener(MouseEvent.MOUSE_OVER, applyAlpha);
textSprite.addEventListener(MouseEvent.MOUSE_OUT, noApplyAlpha);
}
function applyAlpha(event:MouseEvent):void {
textSprite.alpha = 0.5;
}
function noApplyAlpha(event:MouseEvent):void {
textSprite.alpha = 0;
}