小さな星のグラフィックをランダムに表示し、画面にトゥイーンしてから削除するこの機能を作成しました。私は問題を抱えていますが、おそらく10秒後、いくつかの星がトゥイーンの途中でフリーズし、そのままそこにとどまります。
これが私のコードです:
// Create Random Variables.
var xPosition:int;
var yPosition:int;
// Animate Stars.
function stars ():void {
//Defines random starting position for stars.
xPosition = Math.floor(Math.random()*(540))+5;
yPosition = Math.floor(Math.random()*(2))+5;
//Add and position stars.
var newStar:star = new star();
newStar.x = xPosition;
newStar.y = yPosition;
addChild(newStar);
//Tween stars.
var tweenStar:Tween = new Tween(newStar, "y", None.easeOut, yPosition, stage.stageHeight, 4, true);
//Event listener checks star tween.
tweenStar.addEventListener(TweenEvent.MOTION_FINISH, removeStar);
//Remove stars when tween is complete.
function removeStar(e:TweenEvent):void {
removeChild(newStar);
tweenStar.removeEventListener(TweenEvent.MOTION_FINISH, removeStar);
}
}