A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: If statment not working on button

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Posts
    19

    If statment not working on button

    I have the following code on a button:

    on(release){
    if (menu1._visible = false){
    menu1._visible = true;
    }else{
    menu1._visible = false;
    }}

    If I mess around with it it either hides or shows the image, does it need a function? if so can you show me an example.

    I am fine with asp but can't get to grips with this flash stuff, only my 2nd day though!!

  2. #2
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    hi there

    You just have one = in your conditional statement it should be two like ==
    So you could try this:
    Code:
    on(release){
         if (menu1._visible == false){
              menu1._visible = true;
         }else{
              menu1._visible = false;
         }
    }
    A better way to code it( but thats my personal preference) is:

    Code:
    myButton.onPress = function(){
         if (menu1._visible == false){
              menu1._visible = true;
         }else{
              menu1._visible = false;
         }
    }
    Where myButton is the instance name of your button.

    hope this helps a bit
    Last edited by deamothul; 10-30-2005 at 06:23 PM.

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Posts
    19
    Perfect, thanks.

    Do you know anywhere that I can find lots of syntax examples?

  4. #4
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    No problem, glad it helped

    I have written a tutorial about why to use the dot-syntax here:
    http://www.primevector.nl/tutorials/...id=426&tPage=1

    Its not loads of examples, but perhaps its a start
    Last edited by deamothul; 10-30-2005 at 06:34 PM.

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