BookMan
11-07-2003, 07:00 PM
Hi,
I'm working through Billy T's tutorial on animation via Actionscript and I want to vary it just a little.
To move a clip or clips that have been either drawn on the stage or placed there using duplicate, I can do this:
onClipEvent(load){
this._x = 30;
}
onClipEvent (enterFrame) {
if (this._x<500) {
this._x += 15;
}
}
That works great. But if I want to then move the clip back the other way (I'm not worried about acceleration or random movement just yet), I need to add another condition:
} else if (this._x>499) {
this._x -= 15;
}
That doesn't work properly. The clip moves rapidly back and forth 15 pixels at a time once it has reached 500.
Why? Because both conditions are true at the same time! How can I get over this? I've searched this forum and seen quite a few examples of similar things, but they have additional clever stuff like random movement and acceleration and I can't work out what I do and don't need for my simple example.
I know that I should be able to work this out, but I've been trying for ages and my brain is starting to melt...
Thanks for any help.
BookMan
I'm working through Billy T's tutorial on animation via Actionscript and I want to vary it just a little.
To move a clip or clips that have been either drawn on the stage or placed there using duplicate, I can do this:
onClipEvent(load){
this._x = 30;
}
onClipEvent (enterFrame) {
if (this._x<500) {
this._x += 15;
}
}
That works great. But if I want to then move the clip back the other way (I'm not worried about acceleration or random movement just yet), I need to add another condition:
} else if (this._x>499) {
this._x -= 15;
}
That doesn't work properly. The clip moves rapidly back and forth 15 pixels at a time once it has reached 500.
Why? Because both conditions are true at the same time! How can I get over this? I've searched this forum and seen quite a few examples of similar things, but they have additional clever stuff like random movement and acceleration and I can't work out what I do and don't need for my simple example.
I know that I should be able to work this out, but I've been trying for ages and my brain is starting to melt...
Thanks for any help.
BookMan