ok it’s simple as hell but I can’t seem to do it.
I have a movie clip I want to move back and forth between 200 pixels and 600… this is the code i scripted fomr scratch and it doens’t seem to be working for me, it gets to 600 then drops below 600 and doens’t slide back to 200. What can I do?
I hate how you hate hockey…
[AS]
onClipEvent(load){
_x=200;
speed=5;
}
onClipEvent(enterFrame){
_x+=speed;
if(_x>=600 or _x<=200){
speed*=-1;
}
}
[/AS]
to be specific I just don’t watch it. Hating takes effort and I don’t put any effort anywhere when it comes to hockey hehe and thank you for the help, it works like a charm.
you need to keep track of which way the clip is movingm or when it is halfway between 200 and 600 it wont know which way to go
so
var direction=1;
onClipEvent(enterFrame) {
speed = 3.5;
if (this._x>600){
direction = -1;
}
else if (this._x<200){
direction = 1;
}
\when it is between 200 and 600 neither if statement executes
\so direction remains whatever it just was
this._x+=speed*direction;
\speed += a negative number instead of -=
\when direction is -1
correct me if i’m wrong freddie if this it what happens
x starts at 200
speed is 5
every frame x is equal to x+ speed or in this case 5
my mc is moving it is moving 5 pixels at a time
if x>600 or x<200 it makes speed *= -1
when it reaches 600 it multiplies it by -1 making speed -5
speed is now -5 so the x begins to backstep 5 at a time.
when it reaches 200 it again multiplies speed by -1 making it positive 5
and so on and so on
It’s because you don’t watch hockey! Just kidding. To each his own. Read through the last post you wrote to me…My immediate responce in my head was, “exactly”. ‘Speed’ you change to tell how many pixels per loop to travel. When it hits the boundries (200/600) it changes the +/- of the variable ‘speed’; so hence changing the direction. It is a touch complicated. I got it from bit-101 months ago and now it’s all I use.
Saying it’s complicted is the best compliment I’ve had today!! Thanks :beam: