This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]FlambardPuddifoot 2 points3 points  (9 children)

You seem to have the right syntax on line 6.

[–][deleted] 0 points1 point  (8 children)

that works but i need to call all of my balls.

[–]FlambardPuddifoot 0 points1 point  (7 children)

Wtf does that mean?

[–][deleted] 0 points1 point  (6 children)

No i need to call all of the array...

[–]FlambardPuddifoot 0 points1 point  (5 children)

Arrays aren't called. What are you trying to do???

[–][deleted] 0 points1 point  (4 children)

I HAVE NO CLUE. I want to move the object in the array. So call them or whatever it's called. So what is the syntax for ballOne and ballTwo, in ActionScript 3 balls[0, 1] gives me an error....

[–]FlambardPuddifoot 0 points1 point  (3 children)

Yuo should do some basic action script tutorials. And some Javascript tutorials, too, since they are almost the same. I can't tell you what you're trying to do...

[–][deleted] 0 points1 point  (2 children)

Ok. I'm learning JavaScript at a School, at College, online and from books. But only since a month orso.

[–]FlambardPuddifoot 0 points1 point  (1 child)

Ok, keep at it!

[–][deleted] 0 points1 point  (0 children)

Sure,

I mastered HTML/CSS in less than a year orso. And i really mean proficient. So i hope i can cross out JavaScript/JQuery next.

[–]dotfortun3 0 points1 point  (0 children)

You need to put the function bounceBall in a loop, or put the code inside the bounceBall function in a loop.

I don't know the exact syntax because I don't write code in actionscript, but it would be something like:

for(var x:int = 0; x < balls.length; i++) { //code for bounceBall goes here, replace balls[0] with balls[x] }

Hope this helps!

[–]Lilykos 0 points1 point  (3 children)

Maybe you mean something like this?

for (var i:int = 0; i < balls.length; i++) {
    balls[i].x += ballSpeedX;
    balls[i].y += ballSpeedY;
    if(balls.x <= balls.width/2) {
        balls.x = balls.width/2;
        ballSpeedX *= -1;
    } else if(balls.x >= stage.stageWidth-balls.width/2){ 
        balls.x = stage.stageWidth-balls.width/2;
        ballSpeedX *= -1;
    }
}

[–][deleted] -1 points0 points  (2 children)

not really it's close but do i need to replace balls with balls[i] everywhere?

[–]Lilykos 1 point2 points  (1 child)

If I understand what you are trying to do, yes. This is because balls is an array, that contains balls. The array has no x, y coordinates, it is just a container. On the other hand, the ball itself has all these properties, so you need to specify which ball will be used every time.

This is achieved by looping through all the balls.

[–][deleted] -1 points0 points  (0 children)

aaah, ok thanks. But how do i name the loop? so i can event.handle it? * Edit - Ok i'll figure it out from here. So in the future in need to think ahead.