Learn how to a build a cloud-first strategyRegister Now


Input Textfield

Posted on 2009-02-19
Medium Priority
Last Modified: 2013-12-06
I am new to Actionscript 3. How do I write code for this: I want to restrict the text input to numbers 0-9 (no alphabet letters allowed).
Question by:aceKay

Accepted Solution

liamrichards earned 375 total points
ID: 23679736
You want something like this:

package {

  import flash.display.Sprite;
  import flash.text.TextField;
  public class Main extends Sprite {
    public function Main(  ) {
      var field:TextField = new TextField(  );
      field.type = flash.text.TextFieldType.INPUT;
      field.border = true;
      field.background = true;        
      field.restrict = "0-9";  

Author Comment

ID: 23681314
I found this code that worked for me

var theTextField:TextField = new TextField();
theTextField.type = TextFieldType.INPUT;
theTextField.border = true;
theTextField.x = 20;
theTextField.y = 107;
theTextField.scaleX = .2
theTextField.scaleY = .35
theTextField.multiline = false;
theTextField.wordWrap = false;
theTextField.restrict = "0-9"; 
theTextField.defaultTextFormat = Field;

Open in new window


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question