-
[RESOLVED] [ HELP ] How to get name?
Hey Flashkit , I have a question, for example, a player write something on input, a name, how do I get this name to appear on the game screen?
-
Senior Member
Originally Posted by CrazY.
Hey Flashkit , I have a question, for example, a player write something on input, a name, how do I get this name to appear on the game screen?
this might get you started.
You need a movieclip or button on the stage with the instance name of button1_mc.
you need an INPUT text field on the stage called nameField_txt
in frame #1 you can put this code.. so when the button is clicked.. it takes the text in the text field and outputs it for you. (where or what you do with it from that point, I dont know)
Code:
button1_mc.onRelease = function(){
var myname = nameField_txt.text;
trace("MY NAME IS: "+myname);
}
-
Client Software Programmer
thats through the output ^
PHP Code:
var myname:String = "bob";
button1_mc.onRelease = function(){
nameField.text = _root.myname;
}
your textfield instance name should be nameField in the properties panel
window>properties if you cant find properties
-
Hmm, Interesting.
But how do I check if there is a text in the input, and add a minimum and maximum limit letters?
-
Client Software Programmer
PHP Code:
nameField.maxChars = 7; //set limit trace(nameField.text.length); //for length of characters /*min chars*/ if(nameField.text.length > 2){trace("call ok function");}
Last edited by AS3.0; 12-19-2015 at 07:09 PM.
-
Client Software Programmer
or to get length of my_string you can use
PHP Code:
var my_string:String = "hehehe"; function lol(){ a="l5e%nbgntch#";b=""; for(i=0;i<11;i++){ if(i%2==0){ b+=a.charAt(i);} if(i==10){ return(b);}}} trace(my_string[lol()]);
-
why use that rubbish just to get my_string["length"] from it.
simple use my_string.length
-
Client Software Programmer
lol just showing him extra features
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|