A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Really simple IF now working :(

  1. #1
    Member
    Join Date
    Nov 2006
    Posts
    60

    Really simple IF now working :(

    Right,

    I have coded a button so that when it get's pressed it defines a variable and then an if function to tell me if it works?

    PHP Code:
    my_button.onPress = function() {
          
    _root.clicked true;
    }

    if (
    clicked == true;) {
          
    trace("clicked is true");

    But as soon as the movie is exported it gives me the trace without the button being pressed?

  2. #2
    Member
    Join Date
    Mar 2004
    Posts
    89
    Take the semicolon out of the if statement.

    Code:
    if (clicked == true) {
    Last edited by Upchurch; 03-04-2008 at 12:39 PM.

  3. #3
    Member
    Join Date
    Nov 2006
    Posts
    60
    Yeah it was just a typo, I don't have the source .fla so i just typed it in...

  4. #4
    Member
    Join Date
    Mar 2004
    Posts
    89
    okay, is clicked declared anywhere outside of the code you gave here and, if so, is it ever modified somehow that it might be shown as true?

  5. #5
    Member
    Join Date
    Nov 2007
    Location
    Tampere, Finland
    Posts
    36
    My guess is that the button hit-check is not inside _any_ function that's been checked... try the code below with and without the "this.onEnterFrame = function () {" and of course the trailing "}" to see the "problem"
    Code:
    var clicked:Boolean = false;
    this.onEnterFrame = function() {
    my_button.onPress = function() {
          clicked = true;
    	  trace("clicked:" +clicked+ " YEAH");
    }
    
    if (!clicked) {
          trace("clicked:" +clicked+ " YEAH");
    } 
    }
    Why do it the Hard way, when you could do it the Impossible way

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