Input Textfield

Posted on 2009-02-19
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
    LVL 1

    Accepted Solution

    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

    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

    Integrate social media with email signatures

    Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

    Join & Write a Comment

    Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now