A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to enable a button you've disabled?

  1. #1
    Junior Member
    Join Date
    May 2006
    Posts
    24

    How to enable a button you've disabled?

    Hi,
    I'm using Flash MX v6 but I'm not very experienced...

    I've '.enabled=false' a button[1] whilst a movie is running.
    When I close the movie(via another button[2]) I want button[1] to work again.
    I've tried telling button[2] to '.enabled=true' button[1]
    I've also tried '.enabled=false' but neither work.

    Help!
    What can I do?
    Is there a different command I can use?
    Or a clever piece of script?

    All suggestions welcome,
    Cheers,
    Champignon

  2. #2
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    Caution: try to avoid giving the names, button[1], button[2], since they refer to array elements, instead you can use button1, button2.
    Please try this code giving values 0, and 1 to the variable cnt, respectively.
    Code:
    var cnt=0;
    if(cnt==0){
    button1.enabled = true;
    button2.enabled = false;
    }
    if(cnt==1){
    button1.enabled = false;
    button2.enabled = true;
    }
    button1.onRelease = function() {
    trace( "you clicked : " + this._name );
    }
    button2.onRelease = function() {
    trace( "you clicked : " + this._name );
    }
    <signature removed by admin>

  3. #3
    Junior Member
    Join Date
    May 2006
    Posts
    24

    cheers

    thanks very much.
    i'm still a bit confused.
    where do i put this code?
    on button2 or on both buttons or...?

  4. #4
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    Drag both the buttons on to the stage, frame1, layer1, layer2.
    Name them button1, button2 respectively, by opening the properties box.
    Copy and paste the code in layer3 (actions layer).
    please see the attached FLA:
    Last edited by Eager Beaver; 08-19-2007 at 02:23 PM.
    <signature removed by admin>

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