Can someone help me with out the best way to script several MCs (acting as buttons) so that on release(), the alphas on the others tween to 20. When you go to click one of the dimmed button, its alpha should tween back to 100 and the previous one that had the full alpha should now fade to 20.
Logically, I know I need to somehow implement a variable to check the state of the MC and an if statement to script the actual alpha tweens but I’m confused as how to actually implement it. where to put it etc.
If anyone has a small example of something like this or can point me in the right direction, I’d really appreciate it. Am trying to figure it out before my next project starts.
on the movie clip, try something like the following
[AS]
onClipEvent(enterFrame){
this.onPress = function() {
//all other alphas fade up
//this._alpha fade down
}
}
[/AS]
If you put that on all of the movie clips, when they are clicked it should work. If you need help with the actual coding, I might be able to help you out.
Yeah thor is right. You could write a prototype function that would fade down the alphas of all the movie clips except the one that was clicked. You could have a variable for the name of the button and the function would fade all of the ones except the one that had its name passed to the function. I don’t have a lot of time right now to write code (I am at work) but I might be able to help you out later.
Thanks for the example but the buttons should actually do the opposite. The button you click should remain at full alpha. The other MCs should fade. So if you click button 1, that’s the active button, the other two fade in the background. then when you click number 2, number 1 and 3 will fade in the background, etc.
Do you know how to do it using the prototype idea as well?
Awesome. One last question, where is it initially setting the alpha? I want to edit all the buttons to start out at full alpha until you click or rollover the first button rather than everything defaulting to 20.
it doesnt initially set the alpha. You would have to make a counter to do that. It is pretty straighforward. Just make a counter that goes up each time they click the button. If the counter is less than 1, alpha is 100.
Don’t need a timer. Just a counter. make a variable and set its starting value to zero. every time you click one of the buttons, say variable +=1. Have a check saying if the variable is less than 1, all alphas are 100. Not a time, just a variable that goes up.