A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Need help in as2 for mouse click

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    16

    Question 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.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    You could do it like so.
    PHP Code:
    var buttonArray:Array = new Array(button1button2button3button4button5);
    var 
    i:Number;
    var 
    j:Number;

    for (
    0buttonArray.lengthi++)
    {
        var 
    thisButton buttonArray[i];
        
    thisButton.value i;
        
    thisButton.onPress = function():Void 
        
    {
            
    doEnableDisable(this.value);
        };
    }

    function 
    doEnableDisable(arg):Void
    {
        for (
    0buttonArray.lengthj++)
        {
            
    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

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    sure, no problem

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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center