views:

31

answers:

2

In Adobe Flash, I have a movie clip that is added to the stage when the keyboard is pressed. I want it to travel across the screen and disappear once it reaches the edge of the stage. At the moment I use this but the image appears and then stops. Here is my code:

addEventListener(Event.ADDED_TO_STAGE,runtime);

var c = 0
function runtime(){
    while(this.x<800){
        this.x += 12;
    }
    removeChild(this);
}

Thanks

A: 

Unfortunately, it looks as though there is no override for the = operator and so the += 12 is just adding 12 to an integer, not actually redrawing the image. You will have to figure out how the image gets drawn and erased. Perhaps look for a bit blit routine.

Bruce
A: 

Solved the problem :P

changed the first line to

addEventListener(Event.ENTER_FRAME,runtime);

and scrapped the while loop.

matt1024
Yup, while loops execute within a single frame... they can be dangerous if you're not careful.
heavilyinvolved