A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] [ HELP ] How to get name?

  1. #1
    I'm not Crazy :D
    Join Date
    Nov 2015
    Location
    Brazil [<o>]
    Posts
    86

    resolved [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?

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Quote Originally Posted by CrazY. View Post
    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);
    }

  3. #3
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    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

  4. #4
    I'm not Crazy :D
    Join Date
    Nov 2015
    Location
    Brazil [<o>]
    Posts
    86
    Hmm, Interesting.
    But how do I check if there is a text in the input, and add a minimum and maximum limit letters?

  5. #5
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    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.

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    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()]); 

  7. #7
    Senior Member
    Join Date
    Aug 2012
    Posts
    115
    why use that rubbish just to get my_string["length"] from it.

    simple use my_string.length

  8. #8
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    lol just showing him extra features

  9. #9
    I'm not Crazy :D
    Join Date
    Nov 2015
    Location
    Brazil [<o>]
    Posts
    86
    Thank you body :P

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