text input


  • Posts: 161
How can I get the user to input text and then save that text as a attribute?


  • Posts: 161
Ok I have made progress and used some code i found on the internet to input text but how can i make so when I press enter it saves the text inputed as a attribute? This is the code:

import flash.text.TextField;
import flash.text.TextFormat;

var inputField:TextField = new TextField();


inputField.border = true;
inputField.width = 200;
inputField.height = 150;
inputField.x = 75;
inputField.y = 50;
inputField.type = "input";


  • Posts: 248
Should look at the forge first.
CaptainComic's "GUI Widgets" pack will do what you want, I think.

I can't give you a 'simple' answer as to how to put the text into an attribute.  When dealing with code pages or blocks - things get real complicated to explain.

Basically the quick and dirty you'd want to put that inputField into a class with a static public TextField variable, and then create a Keyboard Event in another behaviour with the following block;
  - [Set attribute to [CODE: (classname).inputField.text]]

if you don't know how to make a class, or what 'static public variable' means then you're not ready to use code pages :).  You can do most of what you want with blocks alone, even for complex games.
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!