PDA

View Full Version : [Flash]As2 help again



DarkCloud
12-25-2009, 06:26 PM
ok so I have this code

onClipEvent(load){
this._x = 0;
}
onClipEvent(enterFrame){
this._x += 5;
}
the ball is supposed to move 5 pixels right and stop but for some reason it just keeps on going and does not stop after 5 pixels can you guys tell me what I'm doing wrong...:Cry:

Scorpioxxx
12-25-2009, 06:36 PM
onClipEvent(enterFrame){
this._x += 5;
}

Right, the first bolded part tells you that the script in the backets will repeat constantly while in this frame.

The second bolded part tells you what will be happening constantly in the frame, ie, moving 5 pixels constantly.

This can be solved with either a basic 'if' function of by putting the script into the onClipEvent(load) part.

DarkCloud
12-25-2009, 07:01 PM
thanks scopioxxx I did what you said and put in
onClipEvent(load){
this._x = 0;
}
onClipEvent(enterFrame){
if(this._x<100){
this._x+=5;
}
}

it works =D