Hey guys check this code out:
[AS]
function moveClip() {
if (myClip_mc._x < 400) {
// the _x value is less than 400, so increase _x by 1px,
// and let setInterval execute this function again
myClip_mc._x += 1; // move the clip 1 px to the right
} else {
// the _x value is greater than 400,
// so stop the setInterval from executing anymore
clearInterval(myInterval);
} // end “if myClip_mc._x < 400”
} // end moveClip()
// do this when “myButton_btn” is clicked
myButton_btn.onPress = function() {
// execute the “moveClip” function every 10 milliseconds
myInterval = setInterval(moveClip, 5);
} // end myButton_btn.onPress()
[/AS]
I was wondering, is there a way to change if (myClip_mc._x < 400) { to a relative position of myClip_mc.
I mean, i want myClip_mc to move 100px from it’s current position everytime the button is clicked. Instead of only moving it
if it’s x position is less than 400.
So it needs to somehow check it’s current position everytime the button is clicked and then make it shift from that position.
I know this is a long winded way of doing it but i want it this way so i can use it for something different.
Any ideas?