PDA

View Full Version : How does all that happens?


diasf
02-21-2003, 02:35 PM
Hi everyone
I'm a complete Newbie (big N) to action script. I'm sure this one is easy to answer...
I managed to create a movie with action script... but in fact I can't understand how it worked...
All the actions were created in one movie, and with it a small plane flies over the screen. Something like:
....
plane._x=1
plane._y=1
if plane._x<200 {
plane._x+=1
plane._y+=1
}
...
This is not my real case, it's just to illustrate my question.

And the question is: How do the plane fly? This is just an if statement, but in fact the plane flies until is reached the point 200.200. How does action script (or flash... whatever...) knows this simple script is to be repeated until _x reaches 200?

I know... this is really simple... but I'd like if anyone could explain me.

Thanks.

:confused:

Ricod
02-21-2003, 03:25 PM
Flash knows, because you told it to; "Hey Flash, as long as the x-coordinate of plane is less than 200, move it one pixel in the x-axis and 1 on the y-axis will ya ?" :)

Ona side note : plane._x++; does the same as plane._x+=1;

diasf
02-21-2003, 04:29 PM
Thank you Ricod :)

Maybe I'm thinking in a Javascript way... So the "if..." stuff really means "while ..."?
During each "cycle" what is repeated? Only what is inside the "if..."? Is that so?

:confused:

Ricod
02-21-2003, 05:59 PM
ehrm ... not quite diasf. Sorry for mu confusion. Thats do ... while also in actionscript.

If is only run once ... but if you use it multiple times .... So, if you use the code with the onClipEvent(enterframe) of an mc, then its run once per frame, thus being repeated. (in this case it would result in 12 pixels per second, if you kept the fps rate at 12 (default))