Skip to main content
Known Participant
September 14, 2009
Answered

Disable RollOut Function on Movieclips on Click Function

  • September 14, 2009
  • 1 reply
  • 795 views

I'm doing a basic site with frame labels on the main timeline whose name corresponds to the btn names. A simple  otoAndPlay(evt.target.name);

I have a basic navigation setup of 7 mcs with mouse eventlisteners for CLICK, ROLL_OVER and ROLL_OUT.

Example:

prepare.addEventListener(MouseEvent.CLICK, navigate);
plans.addEventListener(MouseEvent.CLICK, navigate);
retire.addEventListener(MouseEvent.CLICK, navigate);
costs.addEventListener(MouseEvent.CLICK, navigate);
additional.addEventListener(MouseEvent.CLICK, navigate);
enrollment.addEventListener(MouseEvent.CLICK, navigate);
faq.addEventListener(MouseEvent.CLICK, navigate);

Here are my functions that coincide:

function navRollOver(evt:MouseEvent):void
     {

     evt.target.gotoAndStop(2); // each mc is setup to contain rollover art on frame 2
     }

function navRollOut(evt:MouseEvent):void
     {

     evt.target.gotoAndStop(1); // I'm telling mcs to go back to frame 1 where original art is
     }

// but now on the click function I want the rollover art to display static when that particular btn is clicked which is the same art that is on frame

     2 of these movieclips so I add the same method as under the rollover function

function navigate(evt:MouseEvent):void
     {

     evt.target.gotoAndStop(2) // But I'm seeing that the rollout function is conflicting with this

     gotoAndStop(evt.target.name);
     }

Does anyone know a better way to do this so when my mcs are clicked they display the rollover content/art? In essence I'm trying to achieve that when the user clicks a btn it goes to that "page" and the corresponding btn stays highlighted. Pretty standard web navigation technique but I just don't know what the best way to do this in flash is and with  how my site is setup.

Thank you

This topic has been closed for replies.
Correct answer kglad

var lastClicked:MovieClip;

function navRollOver(evt:MouseEvent):void
     {

     evt.target.gotoAndStop(2); // each mc is setup to contain rollover art on frame 2
     }

function navRollOut(evt:MouseEvent):void
     {

if(evt.currentTarget!=lastClicked){

     evt.target.gotoAndStop(1); // I'm telling mcs to go back to frame 1 where original art is

}
     }

function navigate(evt:MouseEvent):void
     {

if(lastClicked!=null){

lastClicked.gotoAndStop(1);

}

lastClicked=evt.currentTarget;

     evt.target.gotoAndStop(2) // But I'm seeing that the rollout function is conflicting with this

     gotoAndStop(evt.target.name);
     }

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 14, 2009

var lastClicked:MovieClip;

function navRollOver(evt:MouseEvent):void
     {

     evt.target.gotoAndStop(2); // each mc is setup to contain rollover art on frame 2
     }

function navRollOut(evt:MouseEvent):void
     {

if(evt.currentTarget!=lastClicked){

     evt.target.gotoAndStop(1); // I'm telling mcs to go back to frame 1 where original art is

}
     }

function navigate(evt:MouseEvent):void
     {

if(lastClicked!=null){

lastClicked.gotoAndStop(1);

}

lastClicked=evt.currentTarget;

     evt.target.gotoAndStop(2) // But I'm seeing that the rollout function is conflicting with this

     gotoAndStop(evt.target.name);
     }