Hi there…
I am trying to build avery simple animation…
Basically i have 3 balls; i want them to come to the screen (left to right) with a little “bouncy” effect and then stop.
I managed to create the animation and the bouncy effect for one ball…
The problem i am having is replicating the animation for each of the balls.
I’d like them to appear one at the time.
So basically:
ball_0 bounce-stop then
ball_1 bounce-stop then
ball_2 bounce-stop.
i include the code…if anybody could help it’ d be great…
Cheers…
D
Code:
var spring:Number = 0.2;
var friction:Number = 0.75;
init();
var id:Number = setInterval(springIn,30);
function init():Void {
//initialize array of targets
targets = new Array(170,110,50);
thumbCount = 3;
for (var i:Number = 0;i<thumbCount;i++){
ball = attachMovie(“ball”,“ball” +i,i);
ball._x = -80;
ball._y = 100;
ball.vx = 0;
ball.vy = 0;
}
}
function springIn() {
for (var i:Number = 0;i<thumbCount;i++) {
ball = this[“ball” +i];
trace(ball);
ball.ax = (targets* - ball._x) * spring;
ball.vx += ball.ax;
ball.vx = friction;
ball._x += ball.vx;
if (Math.abs(ball._x - targets) < 1) {
clearInterval(id);
}
}
}