fs_tigre
July 31st, 2008, 09:24 AM
Hi,
I need some help please. What I want to do is to throw the Sprite (ball) five times, using the for () loop.
What am I missing here? Do I need a timer? If yes, how would I use it?
var yVel = -10;
var xVel = 5;
var yAcc = 1;
var ball:Sprite = new Srprite();
for(var i =0; i < 5; i++)
{
ball.graphics.beginFill(Math.random()* 0x000000, 1);
ball.graphics.drawCircle(0,0,10);
ball.graphics.endFill();
ball.y = 250;
ball.x = 250;
addChild(ball);
addEventListener(Event.ENTER_FRAME, throwBall);
}
function throwBall(evt:Event):void
{
ball.x += xVel;
ball.y += yVel;
yVel += yAcc;
}
Thanks,
fs_tigre
I need some help please. What I want to do is to throw the Sprite (ball) five times, using the for () loop.
What am I missing here? Do I need a timer? If yes, how would I use it?
var yVel = -10;
var xVel = 5;
var yAcc = 1;
var ball:Sprite = new Srprite();
for(var i =0; i < 5; i++)
{
ball.graphics.beginFill(Math.random()* 0x000000, 1);
ball.graphics.drawCircle(0,0,10);
ball.graphics.endFill();
ball.y = 250;
ball.x = 250;
addChild(ball);
addEventListener(Event.ENTER_FRAME, throwBall);
}
function throwBall(evt:Event):void
{
ball.x += xVel;
ball.y += yVel;
yVel += yAcc;
}
Thanks,
fs_tigre