A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Using Variabes with Text Areas

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    6

    Using Variabes with Text Areas

    Hey,

    Im trying to make a game, but want to use specific text input to get points, this is probably simple but it doesnt seem to work for me.

    Essentially I have a text input area on the screen and if the user enters the right value and then clicks continue they get points.



    I have a text input area named numgame and have attached this code to the continue button:

    on (release) {
    if (numgame = "343"){
    _root.score = _root.score + 100;
    gotoAndPlay(536);
    }
    }

    Currently it seems like the if statement isnt even doing anything, the score is added once continue is pressed no matter what is entered. Is there a better/ correct way of doing this.

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    Hey bobs99,

    What I did to get it to work is make sure that instead of giving the input textfield an instance name and using:

    if(numgame.text == "343")

    I would put "numgame" in the var of the input text field. Highlight your text and in the properties there is "Var:", just add your variable and you can use it accordingly.

    use if(numgame == "343) instead of if(numgame = "343

    I think the difference is that it is a strict comparison, while using only 1 equal sign will cause it to be true in some cases.

    on (release) {
    if (numgame == "343"){
    _root.score = _root.score + 100;
    gotoAndPlay(536);
    }
    }

    Don't forget to add "numgame" to input textfield var.

    Hope that helps.

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