开发者

How do I refer to an instance from inside it's own code in Adobe Flash

开发者 https://www.devze.com 2022-12-31 11:31 出处:网络
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

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


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.


Solved the problem :P

changed the first line to

addEventListener(Event.ENTER_FRAME,runtime);

and scrapped the while loop.

0

精彩评论

暂无评论...
验证码 换一张
取 消