A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: What's wrong with this if condition ?

  1. #1
    Member
    Join Date
    Jul 2003
    Location
    Lahore
    Posts
    92

    What's wrong with this if condition ?

    Here's the code I'm using to hide and show a text using one button.

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

    it hides it but doesn't show again, why ? using dynamic text, I also tried only if condition but that also does the same. Thanx
    Nemesis

  2. #2
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    1. You are using the assignment operator "=" rather than the equality operator "==" in your if. (Should be "if (text._visible == true) {")
    2. You have both "if"s testing for true.
    3. You don't need it to be else if, if you are testing mutually exclusive conditions, you only need to test the first one else it is the second one.
    4. This is a shortcut to do the same thing:
    code:

    on (release) {
    text._visible=!text._visible;
    }


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