Skip to content

Instantly share code, notes, and snippets.

@martisj
Created October 29, 2012 22:24
Show Gist options
  • Save martisj/3976938 to your computer and use it in GitHub Desktop.
Save martisj/3976938 to your computer and use it in GitHub Desktop.
random balloon spawner
function spawnRandomBalloons(te:TimerEvent):void
{
var balloons:Array = [new mcBalloonPink(), new mcBalloonGreen(), new mcBalloonRed()];
var rndm:int = Math.floor(Math.random() * 3);
trace(balloons[rndm]);
trace(balloons);
var theBalloon = balloons[rndm];
theBalloon.x = 450;
theBalloon.y = Math.floor(Math.random()*(1 + topBoundary - bottomBoundary)) + bottomBoundary;
trace(theBalloon.y);
//theBalloon.y = Math.floor((Math.random() * 240) - 120);
var balloonTween:Tween = new Tween(theBalloon, "x", None.easeNone, 450, -450, 3, true);
balloonTween.addEventListener(TweenEvent.MOTION_FINISH, destroyTweenedObj);
mcGullGame.addChild(theBalloon);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment