Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : whats wrong here?


TJMonster51
6/3/2004 11:02:26 PM
its scrolls one way then just jumps back to the other end without using the
interval set? how do i fix?

stop();
slider = function () {
myButton._x += 2;
if (myButton._x == 400) {
myButton._x -= 400;
}
};
slip = setInterval(slider, 5);
attachMovie("myButton", "myButton", 1);
myButton.onRelease = function() {
attachMovie("explode", "explode", 2);
explode._x = myButton._x;
removeMovieClip(myButton);
clearInterval(slip);
gotoAndPlay(2);
};
TJMonster51
6/3/2004 11:42:11 PM
the problem isnt the interval time. the problem is that its slides to the right
.. goes to 400 and stops. it wont subtract and go all the way to the left with
out moving it 400 then it goes to the right again. wich i want it to do. but
when it goes left. it just jumps there.
gorlins
6/3/2004 11:55:37 PM
of course it just goes there, that's what your code tells it to do when you say
myButton._x -= 400. Do you want it to slide to the left? Change your slider
function function to:

toggle = 1;
slider = function ()
{
myButton._x += toggle * 2;
if (myButton._x >= 400)
{
toggle = -1;
}
if(myButton._x <= 0)
{
toggle = 1;
}
};
TJMonster51
6/4/2004 12:18:43 AM
Jeckyl
6/4/2004 9:29:01 AM
5 milliseconds is not a very long interval time ! Its probably just going
too fast.

[quoted text, click to view]

AddThis Social Bookmark Button