Bug in my button

Hi,

I have this button which tweens to a color when u rollover or release/press it, and tweens back to its original color when u rollout or press other buttons, much like a history button thing (not the one with back button).

But there is one bug, when i rollover it and rollout very fast, the button does not tween back from where it is, instead it jumps to the last frame and tween back from there =(… how do i solve this?

Please help as this is bugging me >_<’

i don’t think you’ll be able to fix that bug as your telling the button to go to a frame [U]further along[/U] the timeling than where the buttong gets up to during the time that the mouse is over it.

eg, the mouse stays for 2 frames but then the ActionScript tells the player to jump to frame 10 and rewind or however you did it.

However as im not to advanced at ActionScript there may be a way of doing it efficently that i am now aware of. sorry

The way i’ve always made buttons with tweens like that has been to make the button actually a movie clip, with an invisible button under it that triggers the tween. I program a function in the root timeline that initiates when rolling over the invisible button is ‘true’. This allows you to play the tween forward and backward smoothly, no matter how far through the animation it is. Here’s how you do it. In the animation for your button, make it a movie clip. Put a stop(); command in the first and last frame of the animation. Give the movie clip an instance name. I’ll use ‘fade_mc’ as the instance name in my example. On the root timeline, put this code:


fade_mc.onEnterFrame = function(){
     if(fade){
          fade_mc.nextFrame();
     }else{
          fade_mc.prevFrame();
     }
}

Then on your invisible button, put this code:


on(rollOver){
     _root.fade = true;
}

on(rollOut, dragOut){
     _root.fade = false;
}

Hope that helps. I can post an example .fla if you want.