its great,its working but what i want to know is how can we make the movement stop on determined _x position,i’ve tryed to put an if statement to stop when it reaches some _x position ,it worked but it didn’t work smoothly it gets the movieclip to _x position without the smoothness and i’de like to keep the smooth movement
can someone help me please?
thanks
i’ve tried to use it as you said but it doesn’t work ,when the movieclip reachs the _x=100 it continues to move i don’t know why somehow it seems that it doesn’t “see” the If condition
MLK - love the footer - gotta click it everytime I see it!!
What I do when I want an AS movement to stop is either tell speed to equal 0. This is what I mean:
[AS]
onClipEvent(enterFrame) {
speed = 1;
this._x += speed;
if (this._x >= 100){
speed=0;
}
}
[/AS]
Can’t move without the pedal down. Hope that helps!!
(-:
if you want to stop the MC smoothly, you may want to use easing. an example:
[AS]
myMC.newx = 400
myMC.speed = 8
myMC.onEnterFrame = function () {
this._x = this._x-(this._x - newx)/this.speed
}[/AS]
newx is where you want the MC to stop and speed is how fast you want it to get there. i didn’t check out which tutorial you read so i may be wrong :*(
ok guys
thanks for all the help but i have figure out myself a solution for this here it is
onClipEvent(EnterFrame){
count=this._x;
if (count==100){
this.stop();
}
else{
speed = 1;
this._x += speed;
count=this._x;
}
}
the only thing is to put the condition right which means we have to see first if the movieclip has already reached the position we want and if its true we stop else we continue to move
*Originally posted by zylum *
**if you want to stop the MC smoothly, you may want to use easing. an example:
[AS]
myMC.newx = 400
myMC.speed = 8
myMC.onEnterFrame = function () {
this._x = this._x-(this._x - newx)/this.speed
}[/AS]
newx is where you want the MC to stop and speed is how fast you want it to get there. i didn’t check out which tutorial you read so i may be wrong :*(