I'm tryimg to make a platformer game were the level moves instead of you, but for some reason my while loop is a infinite loop. env is the level, "this" is the character and lev is the ground. the code is so that my guy doesn't sink in the ground, and if you know a better way to state that in flash the please show.
levellocationx= env._x -xspeed
levellocationy= env._y -yspeed
while-loops and for-loops execute from beginning to end before anything is updated on-stage. so, they are not appropriate for use in animating anything.
use an onEnterFrame loop or setInterval() loop for animation.
yes ,but what im trying to do is have my character hit the ground and pop up one pixel above the ground before the next frame, well except inversely where the ground moves instead. For that to work I would need a while loop.
if you only wantted to move 1 pixel, you wouldn't need a while-loop. if you need to move a variable amount of pixels you could use a while-loop. but you better make sure that hitTest will be false when that variable increments enough.