-
Need help in as2 for mouse click
Hi all,
I am using flash professional cs6... In my flash file I have some ten buttons. whenever I click a button it opens the relevant text which i have given in a movieclip. Now my doubt is when I click a button I want it to be disabled, and when i click another button i want the already clicked button to be re-enabled and come back to the active state.
is there a global action to achieve this rather than going to each button and give enable action.
Please help me. thank you.
-
.
Hi,
You could do it like so.
PHP Code:
var buttonArray:Array = new Array(button1, button2, button3, button4, button5);
var i:Number;
var j:Number;
for (i = 0; i < buttonArray.length; i++)
{
var thisButton = buttonArray[i];
thisButton.value = i;
thisButton.onPress = function():Void
{
doEnableDisable(this.value);
};
}
function doEnableDisable(arg):Void
{
for (j = 0; j < buttonArray.length; j++)
{
buttonArray[j]._alpha = 100;
buttonArray[j].enabled = true;
}
buttonArray[arg]._alpha = 25;
buttonArray[arg].enabled = false;
}
simply swap button1, button2, button3, button4, button5 for the names of your buttons on the stage or rename your buttons to the names I have used.( I used 5 buttons only for my testing purposes)
if you need any explanantion, I'm sure we can tell you.
If you have real problems better attach your *.fla
-
.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|