I got this stupid glitch in the linear tween when the birds fly from left to right (i.e. sometimes they freeze).
Live : http://tli-temp.heroku.com/
Code :
package tli {
import flash.events.TimerEvent;
import flash.utils.Timer;
import com.greensock.TweenMax;
import com.greensock.easing.Linear;
public class Birds {
private var birds:Array;
public function Birds():void {
birds = TLI.birds as Array;
var i:uint = 4;
while (i > 0) { new_bird(i); --i; }
}
private function new_bird(nr:uint):void {
var b:Bird = new Bird();
b.name = 'Bird nr.' + nr;
b.scaleX = 0.23;
b.scaleY = 0.23;
b.x = -100;
TLI.stage.addChild(b);
birds.push(b);
setTimeout(function():void { tween_bird( birds[0] ); birds.shift() }, rndm(5500, 500));
}
private function tween_bird(bird:Bird):void {
bird.x = -100;
bird.y = rndm(TLI.stage.stageHeight - TLI.sea.height - 80, 50);
TweenMax.to( bird, rndm(55,35), {
x: TLI.stage.stageWidth + 100, ease: Linear.easeNone,
onComplete: tween_bird, onCompleteParams: [bird]
});
}
private function rndm(max:uint, min:uint=0):uint { return Math.floor( Math.random() * (max-min) ) + min }
}}
Anyone got an idea how I could fix this?