Skip to main content
December 9, 2010
Answered

How to put a var on a password box using AS3?

  • December 9, 2010
  • 1 reply
  • 1032 views

Hi,

I am having a problem trying to make a little game. I want to create a password box using input text but i dont know how to put a variable on my input text. It's telling me i can only do it with AS2. What I am trying to do is that if you enter (in the password box) a specifically word like  ''Pizza'', your sended to ''Question 1'' using go to and stop. I tryed to create once myself with this tutorial (http://animation.about.com/od/flashanimationtutorials/ss/simplepassword_2.htm) but I think it's for AS2 cause i cant place a Var on as3. Can someone tell me how to put a Var on my inputtext? My Input text occurence is called ''Pass'' and is already set as ''Password'' (not single line or multi line). Someone Help please. Ive been looking for 6 hour on how to cade a var myself and i juste dont understand.

This topic has been closed for replies.
Correct answer Ned Murphy

Yes, something like that though not literally... it would be...

if(tField.text == "Pizza"){

     gotoAndStop(17);

}

But another way you could approach it would be to label the frames using the words they need to enter.  That way when they click the button you don't need to test anything and can just use...

gotoAndStop(tField.text);

1 reply

Ned Murphy
Legend
December 9, 2010

You cannot create a var on a textfield in AS3, and you don't need to.  I am not sure of the machanics of what you are trying to do from your description, but you can use the 'text' property of a textfield to see what is in the textfield.  If you give the textfield an instance name, say you name it "tField", then to get the value in it you just use... tField.text

What interaction are you expecting in terms of someone entering a value?  Do they click a button after they enter the value to trigger moving to another frame?

December 9, 2010

Yea, I want them to click a ''Enter'' Button and then getting redirected depending of wich word they entered. For exemple, if they enter ''Pizza'' they're sended to Frame 17, if they enter ''Pogo'', they're sended to frame 22, and ''Coco'' they're going to Frame 30.

So if I understand, the code must be something like ''if tfield.text = Pizza, go to frame 17'' ..... Or something like that..?

Ned Murphy
Ned MurphyCorrect answer
Legend
December 9, 2010

Yes, something like that though not literally... it would be...

if(tField.text == "Pizza"){

     gotoAndStop(17);

}

But another way you could approach it would be to label the frames using the words they need to enter.  That way when they click the button you don't need to test anything and can just use...

gotoAndStop(tField.text);