PDA

View Full Version : how do you do this?


thearc
01-11-2007, 01:32 AM
Check out the links at the bottom left under services. I know how to do the over and out effects of the links but how do they highlight the selected links and then unhighlight the previously selected links after another link is clicked?

http://www.2advanced.com/#services/design

_lithium
01-11-2007, 01:59 AM
When i do this i usually create my navigation dynamically, assign each button an id, and pump the button into an array. then write a function to handle the activation of the buttons by their id.

for example:



var buttonArray:Array = [];

// attach buttons;

for ( var i:Number = 0; i < 10; i++ )
{
var but:MovieClip = this.attachMovie("but", "but" + i, i );
but._x = 10;
but._y = 10 + ( i * but._height );
but.id = i;
but.onRelease = function()
{
this._parent.activateButton ( this.id );
}
buttonArray.push ( but );
}

// activation function

function activateButton ( id:Number )
{
for ( var i:Number = 0; i < buttonArray.length; i++ )
{
if ( i == id )
{
buttonArray[i].active = true;
// make any calls to change the highlight state on this button
}else
{
buttonArray[i].active = false;
// make any calls to change the highlight state of this button to inactive
}
}
}



hope it helps,

Cheers,

/lith

thearc
01-11-2007, 06:52 AM
Thanks for the reply!

I'm not quite that AS savvy to understand the above code...is there another way getting the same effect if i'm not using arrays?

I'm using duplicated movieclips for my buttons with assigned instance names and then calling the over and out states of these movie clips using AS.

here is my AS

this.company_btn.onRollOver=function(){
company_btn.gotoAndPlay("over");
}
this.company_btn.onRollOut=function(){
company_btn.gotoAndPlay("out");
}

this.mission_btn.onRollOver=function(){
mission_btn.gotoAndPlay("over");
}
this.mission_btn.onRollOut=function(){
mission_btn.gotoAndPlay("out");
}


this.ftv_btn.onRollOver=function(){
ftv_btn.gotoAndPlay("over");
}
this.ftv_btn.onRollOut=function(){
ftv_btn.gotoAndPlay("out");
}

this.corporate_btn.onRollOver=function(){
corporate_btn.gotoAndPlay("over");
}
this.corporate_btn.onRollOut=function(){
corporate_btn.gotoAndPlay("out");
}

this.event_btn.onRollOver=function(){
event_btn.gotoAndPlay("over");
}
this.event_btn.onRollOut=function(){
event_btn.gotoAndPlay("out");
}

this.artistdev_btn.onRollOver=function(){
artistdev_btn.gotoAndPlay("over");
}
this.artistdev_btn.onRollOut=function(){
artistdev_btn.gotoAndPlay("out");
}


this.project_btn.onRollOver=function(){
project_btn.gotoAndPlay("over");
}
this.project_btn.onRollOut=function(){
project_btn.gotoAndPlay("out");
}

this.career_btn.onRollOver=function(){
career_btn.gotoAndPlay("over");
}
this.career_btn.onRollOut=function(){
career_btn.gotoAndPlay("out");
}

thanks!