Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //var balloons:Array = [mcBalloonPink, mcBalloonGreen, mcBalloonRed];
- //class names in library: Balloon1, Balloon2, Balloon3
- var balloons:Array=[];
- var tweens:Array = [];
- function spawnRandomBalloons(te:TimerEvent):void
- {
- var i:uint = Math.floor(Math.random() * 3)
- var cls:Class = getDefinitionByName( "Balloon" + i ) as Class;
- var balloon = new cls();
- balloon.x = 450;
- balloon.y = Math.floor(Math.random()*(1 + topBoundary - bottomBoundary)) + bottomBoundary;
- var tween:Tween = new Tween(balloon, "x", None.easeNone, 450, -450, 3, true);
- tween.addEventListener(TweenEvent.MOTION_FINISH, destroyTweenedObj);
- mcGullGame.addChild(balloon);
- balloons.push(balloon);
- tweens.push(tween);
- }
- function checkBalloons(event:Event):void
- {
- for(var i:uint=0; i balloons.length; i++)
- {
- if(balloons[i].hitTest(bird))
- {
- mcGullGame.removeChild(balloons[i]);
- balloons.splice(i,1);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement