當我將鼠標放在buttonSprite上時,它將displaySprite添加到舞臺上,當我將buttonSprite鼠標移出時,displaySprite被移除。Actionscript 3:mouse_over&mouse_out導致錯誤#1009?
我的問題是,當我快速地將鼠標移出並移出buttonSprite幾次時,displaySprite不會被刪除,並顯示錯誤消息(錯誤#1009)。即使我輸入「displaySprite = null」,它仍然不起作用。有什麼建議麼?謝謝
var buttonSprite:Sprite = new Sprite();
addChild(buttonSprite);
buttonSprite.addEventListener(MouseEvent.MOUSE_OVER, overSprite);
var displaySprite:Sprite;
function overSprite(e:MouseEvent):void{
displaySprite = new Sprite();
addChild(displaySprite);
buttonSprite.addEventListener(MouseEvent.MOUSE_OUT, outSprite);
}
function outSprite(e:MouseEvent):void{
removeChild(displaySprite);
displaySprite = null;
}