Special button function?

hello,

i am creating a series of navigational menus in flash, all linked to each other. when the user presses a button on one menu, another pops up but the original menu also stays on screen. On the original menu, I would like all of the non-pressed buttons’ alpha to degrade by half. I realize that I can just specify which specific buttons’ alpha I would like to degrade within the onRelease function of the button, but this could get cumbersome over many menus and buttons. Is there a function that can be written which would degrade the alpha of all buttons EXCEPT for the one that was just pressed?

Thanks for any help.

PS Im using AS 2 for this.

// assuming that your movieclips are called btn1,btn2,btn3…btn6
// and you want to change the alpha of all other to 40% except the selected one

for(var i=1;i<=6;i++)
{
var mc:MovieClip=this[“btn”+i];
mc.id=i;
mc.onRollOver=rollIn;
mc.onRollOut=reset;
}

function rollIn()
{
fadeAllBut(this.id);
}

function reset()
{
for(var i=1;i<=6;i++)
{
var mc:MovieClip=this[“btn”+i];
mc._alpha=100;
}

}

function fadeAllBut(id)
{
for(var i=1;i<=6;i++)
{
var mc:MovieClip=this[“btn”+i];
if(i!=id)
{
mc._alpha=40;
}
}
}

// please let me know if you have any problems with this

I just got back to this problem,

Thanks for your help. The code below worked. However,

I was wondering if you (or anyone) knew how I could put all of this into a function which will work when I rollover the desired button. The problem is that I also want other things to happen, specific to each button, when you rollover them. For example when I put this code:

btn1.onRelease = function(){
gotoAndPlay(2);
}

the movie will move to frame 2 but it will ignore the code for the fading buttons, and Im not sure why…?

Any help would be great, thanks.

[quote=sparkdemon;2325472]// assuming that your movieclips are called btn1,btn2,btn3…btn6
// and you want to change the alpha of all other to 40% except the selected one

for(var i=1;i<=6;i++)
{
var mc:MovieClip=this[“btn”+i];
mc.id=i;
mc.onRollOver=rollIn;
mc.onRollOut=reset;
}

function rollIn()
{
fadeAllBut(this.id);
}

function reset()
{
for(var i=1;i<=6;i++)
{
var mc:MovieClip=this[“btn”+i];
mc._alpha=100;
}

}

function fadeAllBut(id)
{
for(var i=1;i<=6;i++)
{
var mc:MovieClip=this[“btn”+i];
if(i!=id)
{
mc._alpha=40;
}
}
}

// please let me know if you have any problems with this[/quote]

timeline is **** and ******************************** to make a point

you shouldn’t be trying to move around the timeline with even basic AS

you will need to make pages _visible = false and _visible = true

with the same priniple as the button code

plus it is in a function… two plus

Not sure what you mean with all those asteriks…??? Or much else of what you are trying to say… pretend Im in grade 4…

[quote=randomagain;2329183]

you shouldn’t be trying to move around the timeline with even basic AS

you will need to make pages _visible = false and _visible = true

with the same priniple as the button code

plus it is in a function… two plus[/quote]

Oh I see…

All of the menus are appearing/disappearing by toggling on or off the visibility.
However I also want an arrow to appear that kind of indicates which menu button was pressed to get to the newer menu which appears… the way I can think of doing this is via the timeline, with the arrow in different positions depending on the frame.
Im sure there is a way to make said arrow appear on stage with _visible = true as well, and I could modify its x and y coordinates, but I would have have the cooridinates correspond to the current coordinates of the button that was just pushed, but that kind of actionscript is a little above my level.

So this can all lead to a nice question:

I have 4 menus with 5 buttons in each menu. Only the top menu (menu1) is visible at the beginning. User hits any of the 5 buttons in menu1 and onRelease:

  • button that is hit stays at 100% alpha, others fade to 50%
  • red arrow appears below button that was hit.
  • 2nd level menu appears below

(process of course starts all over again for this new menu).

Menu’s disappearing/reappearing is no problem. Im halfway there on the alpha fade issue, but have no idea how to do this arrow…

Anyone…?

Thanks!

import mx.transitions.Tween;

//i assume that your arrow remains on the root level.

//press on any button or menu item

var tw:Tween=new Tween(arrow_clip, “_x”, mx.transitions.easing.None.easeIn,arrow_clip._x,_root._xmouse,2, true);

// put the above code in a function and call it with every menu item click (when it is selected);