• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Roll on Roll OFF issue

New Here ,
May 27, 2010 May 27, 2010

Copy link to clipboard

Copied

Hi all, I am having a problem with my roll on / roll off code.  I previously used a hit test code which ran into problems, and I am not using this code supplied to me from a member from this forum.  Everything works but I still have the same problem which is when I quickly roll off one button to another, the preceeding button "sticks" at one of the on frames.  If you move the mouse quickly over the nav the buttons animate on, but some stick....how can I force the animated link to play all the way back to frame 1, even if I go over a new button or leave the flash window / nav in xhtml/css.

Here is my code, I moved the event listeners to the bottom so you can see the main part of the code first:

stop();


function overF(e:MouseEvent){
    var mc:MovieClip = MovieClip(e.currentTarget);
    if(!mc.hasEventListener(Event.ENTER_FRAME)){
        mc.removeEventListener(Event.ENTER_FRAME,prevF);
    }
    mc.play();
  
}
function outF(e:MouseEvent){
    var mc:MovieClip = MovieClip(e.currentTarget);
    if(mc.currentFrame>1){
        mc.prevFrame();
        if(!mc.hasEventListener(Event.ENTER_FRAME)){
            mc.addEventListener(Event.ENTER_FRAME,prevF);
        }
    }
}
function prevF(e:Event){
    var mc:MovieClip = MovieClip(e.target);
    if(mc.currentFrame>1){
        mc.prevFrame();
    } else {
        mc.removeEventListener(Event.ENTER_FRAME,prevF);
    }
}

b1.addEventListener(MouseEvent.ROLL_OVER, overF);
b1.addEventListener(MouseEvent.ROLL_OUT, outF);

b2.addEventListener(MouseEvent.ROLL_OVER, overF);
b2.addEventListener(MouseEvent.ROLL_OUT, outF);

b3.addEventListener(MouseEvent.ROLL_OVER, overF);
b3.addEventListener(MouseEvent.ROLL_OUT, outF);

b4.addEventListener(MouseEvent.ROLL_OVER, overF);
b4.addEventListener(MouseEvent.ROLL_OUT, outF);

b5.addEventListener(MouseEvent.ROLL_OVER, overF);
b5.addEventListener(MouseEvent.ROLL_OUT, outF);

b6.addEventListener(MouseEvent.ROLL_OVER, overF);
b6.addEventListener(MouseEvent.ROLL_OUT, outF);

b7.addEventListener(MouseEvent.ROLL_OVER, overF);
b7.addEventListener(MouseEvent.ROLL_OUT, outF);

b8.addEventListener(MouseEvent.ROLL_OVER, overF);
b8.addEventListener(MouseEvent.ROLL_OUT, outF);

b9.addEventListener(MouseEvent.ROLL_OVER, overF);
b9.addEventListener(MouseEvent.ROLL_OUT, outF);

b10.addEventListener(MouseEvent.ROLL_OVER, overF);
b10.addEventListener(MouseEvent.ROLL_OUT, outF);

b11.addEventListener(MouseEvent.ROLL_OVER, overF);
b11.addEventListener(MouseEvent.ROLL_OUT, outF);

b12.addEventListener(MouseEvent.ROLL_OVER, overF);
b12.addEventListener(MouseEvent.ROLL_OUT, outF);

b13.addEventListener(MouseEvent.ROLL_OVER, overF);
b13.addEventListener(MouseEvent.ROLL_OUT, outF);

b14.addEventListener(MouseEvent.ROLL_OVER, overF);
b14.addEventListener(MouseEvent.ROLL_OUT, outF);


b15.addEventListener(MouseEvent.ROLL_OVER, overF);
b15.addEventListener(MouseEvent.ROLL_OUT, outF);


b16.addEventListener(MouseEvent.ROLL_OVER, overF);
b16.addEventListener(MouseEvent.ROLL_OUT, outF);

b17.addEventListener(MouseEvent.ROLL_OVER, overF);
b17.addEventListener(MouseEvent.ROLL_OUT, outF);

TOPICS
ActionScript

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 27, 2010 May 27, 2010

Copy link to clipboard

Copied

Why you such complicate it? Try this:

b1.addEventListener(MouseEvent.ROLL_OVER, overF);
b1.addEventListener(MouseEvent.ROLL_OUT, outF);

function overF(e:MouseEvent):void

{

     MovieClip(e.target).gotoAndStop(2); // assuming that in frame 2 is your roll over state
}

function outF(e:MouseEvent):void

{

      MovieClip(e.target).gotoAndStop(1); // assuming that in frame 1 is your roll out state
}

To all other buttons just assign the same listeners.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2010 May 27, 2010

Copy link to clipboard

Copied

thanks for the answer, but that wont work for an animated roll on and roll off button.  I need th have an animation play on and off, when the user is over or off the button.

I see this all over the web, there isn't an industry standard way to create a roll on/roll off animation for links in Flash that isn't buggy?

anyone?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 27, 2010 May 27, 2010

Copy link to clipboard

Copied

Than, for animated rollOver/Out effects do this:

Let for egzample the 1st frame of a button movie clip contains button's base state, put there stop(); command as well.

RollOver animation runs from 2nd to 10th frame (put stop(); in 10th frame). RollOut animation: frames 11 - 20 ( stop(); in 20th frame).


With a frames structure like this use the following rollOver/out handlers:

function overF(e:MouseEvent):void

{

      MovieClip(e.target).gotoAndPlay(2);
}

function outF(e:MouseEvent):void

{

       MovieClip(e.target).gotoAndPlay(11);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2010 May 29, 2010

Copy link to clipboard

Copied

I did not check it in action but still try the following:

stop();
configureListeners();
function configureListeners():void {
     var currentButton:MovieClip;
     for (var i:int = 0; i < 18; i++ ) {
          currentButton = MovieClip(this["b" + i]);
          currentButton.addEventListener(MouseEvent.ROLL_OVER, overF);
          currentButton.addEventListener(MouseEvent.ROLL_OUT, outF);
     }
}

function overF(e:MouseEvent):void{
    var mc:MovieClip = MovieClip(e.currentTarget);
     mc.removeEventListener(Event.ENTER_FRAME, playBackward);
     mc.addEventListener(Event.ENTER_FRAME, playForeward);
}

function outF(e:MouseEvent):void{
    var mc:MovieClip = MovieClip(e.currentTarget);
    mc.removeEventListener(Event.ENTER_FRAME, playForeward);
     mc.addEventListener(Event.ENTER_FRAME, playBackward);
}

function playBackward(e:Event):void{
    var mc:MovieClip = MovieClip(e.target);
    if (mc.currentFrame > 1) mc.prevFrame();
    else mc.removeEventListener(Event.ENTER_FRAME, playBackward);
}

function playForeward(e:Event):void{
    var mc:MovieClip = MovieClip(e.target);
    if (mc.currentFrame < mc.totalFrames) mc.nextFrame();
    else mc.removeEventListener(Event.ENTER_FRAME, playForeward);
}

Message was edited by: Andrei1

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 29, 2010 May 29, 2010

Copy link to clipboard

Copied

Why don't you just turn the button into a movieclip and animate it in the movieclip.

Then you would not need all of the code, and the confusing b1, b2, ....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2010 May 29, 2010

Copy link to clipboard

Copied

LATEST

They ARE MovieClips...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines