A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: SimpleButton enabled property not working?

  1. #1
    Member
    Join Date
    Sep 2007
    Posts
    80

    SimpleButton enabled property not working?

    Hi,

    I have a button on the stage that when it is clicked I want to disable it until an animation is done playing then re-enable it.

    Code:
    button.addEventListener(MouseEvent.CLICK, onButtonClicked);
    
    function onButtonClicked(e:MouseEvent):void {
        e.target.enabled = false;
    
        //do the animation using TweenLite from blog.greensock.com
        //i call an on complete handler that sets the button's enabled
        //property back to true after the tween.
    }
    The code works and fires everything at the proper time. The problem is that when i set enabled to false, the button no longer uses the hand cursor, which is what i expected.... but i can still click on the button and the click event fires! I have to actually use removeEventListener and then add the listener back to make this work. While that is ok... i'm just curious why enabled is not working as it is supposed to... or am I reading the docs wrong?

    Has anyone else run into this?

    Thanks!

  2. #2
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    enabled isnt going to do what you think it would. do this :

    Code:
    function onButtonClicked(e:MouseEvent):void {
        button.removeEventListener( MouseEvent.CLICK, onButtonClicked );
        button.buttonMode = false;
        button.useHandCursor = false;
    }
    then in your complete handler ,

    Code:
    function onButtonAnimationComplete() : void {
        button.addEventListener( MouseEvent.CLICK, onButtonClicked );
        button.buttonMode = true;
        button.useHandCursor = true;
    };

  3. #3
    Member
    Join Date
    Sep 2007
    Posts
    80
    Thanks!

    That's what I ended up doing, I was just making sure I wasn't somehow using it incorrectly seeing as how this is what's in the docs haha.

    A Boolean value that specifies whether a button is enabled. When a button is disabled (the enabled property is set to false), the button is visible but cannot be clicked.

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