• Home
  • About
  • Contact Us
  • Gallery
  • Video
  • Archives
  • Site Map
Grab the RSS feed

FlashBannerOnline

FlashBannerOnline
  • Home
  • FlashBannerOnline
  • Free Downloads
  • General
  • Tutorials
    • Adobe AIR
    • CSS
    • Fireworks
    • Flash
      • ActionScript
    • FLEX
    • Javascript
      • JQuery
      • MooTools
    • PHP

TextField in AS3

  • ActionScript, Tutorials

    Posted on November 18th, 2009

    Written by Behrouz Pooladrag

    Related Posts

    • Flash Optimization – Activate & Deactivate Events
    • Flash Optimization – Object Pooling
    • Flash Optimization – Reusing Objects

    Tags

    "actionscript 3 score ", actionscript, actionscript 3 how to determine what is in a textfield, actionscript 3 press enter textbox, actionscript 3 textbox, actionscript 3 textfield == array, actionscript textfield press enter, AS3, as3 addchild text box, as3 creating a text field which can be edited by the user, as3 declare a textbox, as3 display text on screen, as3 mysql banner and text, as3 selectable textfield, as3 static text, as3 text field, as3 textfiedl optimization, as3 textfield, as3 textfield type, as3 textfield with quotes, as3 write text on screen, banner flash as3 text, banner flash tet, decimal in textfield in as3, Flash, flash as3 addchild text inside a object, flash as3 textarea tutorial, flash as3 textfield cut off, flash as3 textfield problem text cut, flash as3 textfield.type, flash filer to textfield as3, how to create a textbox in addchild in as3, how to create a textfield name in flash as3, how to put message box in as3, mysql display row as3 textfield, new line in textbox actionscript 3, score counter flash as3, text field as3, text field in as3, textbox actionscript 3, TextField, textfield as3, textfield as3 flash, textfield in as3, textfield line new as3, textfield name as3, textfield types as3, textfieldtype.dynamic with actionscript 3
    TextField in AS3

    1. Create a – Flash File(ActionScript 3.0)

    2. Now go to your Actions tab, you can do this by pressing F9, or going to Window – Actions in your menu bar.

    3. In your “Actions – Frame” tab, type the code:

    var textBox:TextField = new TextField();

    var Declares you are making a variable.
    textBox Name I chose for the box of text (or text object) we are dealing with.
    TextField Says you are making a text field.
    new TextField() Pretty much says you are making a new text field.

    textBox.x = 10;

    This line declares the X value location will be 10 units right of the left edge of the flash window.
    The X value controls how far left or right something is. If X is 0, then the object will be on the
    left side of the screen, and the higher the value, the further right it will be. For those who have
    programmed in ActionScript 2.0, you may notice that it is just .x instead of ._x, which is no longer used.

    textBox.y = 10;

    Much of the same as the last line. If Y is 0, then the object will be placed at the top of the screen.
    The higher the value of Y, the lower on the flash window the object will be.

    textBox.width = 500;

    This sets the width of the text box. If the width is too small, then the text will be cut off, and you
    will not be able to see all of your text.

    E.

    textBox.text = “Hello World”;

    This line of code will determine what will be said in your text box. The quotes (” or ‘) around the text are required.

    textBox.type = TextFieldType.DYNAMIC;

    This line says what type of text box it will be. There are 3 different types:

    INPUT – This is a text box you can edit the text of. You can use this for users to enter numbers, names, or other text. This text is selectable.

    DYNAMIC – This is a text box that can only be edited by code. You can use it to show a user’s score, or other information that can change. This text is selectable.

    Static – This is a type of text you can not create with code. You must use the graphic tools to create static text. This type of text is not selectable.

    textBox is the name of our text object again.
    type is a another attribute you can declare.
    TextFieldType just says that you are declaring the type of text field it is going to be. (Yeah, I feel a lot of this language is pretty redundant at times…)
    DYNAMIC is one of your choices what type of text box you have.

    addChild(textBox);

    This adds the object to the display list. A list of objects that will be put on the screen when you run your SWF.

    Hold Control and press Enter. This will render your SWF to show you what your results are.
    You can also go to Control on your menu bar, then Test Movie to do the same thing.

    Complete Code:

    var textBox:TextField = new TextField();
    textBox.x = 10;
    textBox.y = 10;
    textBox.width = 500;
    textBox.text = “Hello World”;
    textBox.type = TextFieldType.DYNAMIC;
    addChild(textBox);
    Done ;)
    This entry was posted on Wednesday, November 18th, 2009 at 9:55 am and is filed under ActionScript, Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

    You might also like

    FullScreen in AS3 Notes: This tutorial covers HTML changes as well. Flash requires an HTML to be in opened in your browser and load...
    The Display List in AS3 The display list is the system by which objects are displayed on the screen using ActionScript 3.0. It is one of...
    Run Applications from a Flash (AS3) Projector EXE So i’ve been writing some CD launchers recently with some handy tools on. One thing i had major trouble with...
    Using the Loader Class in AS3 The Loader Class is an ActionScript class that lets us load external assets (such as images and Flash files) at...
  • 2 Comments

    Take a look at some of the responses we've had to this article.

    1. thsnks
      Posted on September 1st

      Thanks for this tut. I was finding right that

    2. Behrouz Pooladrag
      Posted on September 5th

      you’re welcome ;)

  • Post a Comment

    Let us know what you thought.

  • Name:

    Email (required):

    Website:

    Message:

  • Ad Ad

  • FlashBannerOnline.Com

  • Subscribe

    Enter your email address:

    | More

  • Blogroll
    • Random Flash Banner!
  • Tag Cloud

    • actionscript addChild addEventListener Adobe AIR Air Animation AS2 AS3 as3 preloader Banner beginFill BitmapData blog.flashbanneronline.com Class CSS Date Class draw Flash flash.net.URLLoader flash banner free flash banner generator flash banner happy new year flashbanneronline FlashBannerOnline.com flash banner online free flash player function game getChildIndex Javascript lightbox Loading Mysql new year flash banner Object Optimization package PHP Sprite tot Tweener URLLoader URLRequest web XML
  • Recent Comment
    • Behrouz Pooladrag on Flash Optimization – Freezing And Unfreezing Objects
    • Valerie on Flash Optimization – Freezing And Unfreezing Objects
    • FlashLord on RSS Reader for FlashBannerOnline Blog!
    • Behrouz Pooladrag on Using ActionScript 3.0 with PHP Loading External Variables
    • LUN on Using ActionScript 3.0 with PHP Loading External Variables
  • RSS FlashBannerOnline
    • Happy New Year 2012 & Gift!
    • New Templates Oval Light Added to Flash Banner Online
    • FlashBannerOnline started in Arabic language
    • Happy New Year 2011
    • New Templates Christmas 2011 Added at Christmas!
    • New Templates angel animate Added to Flash Banner Online
    • Added Tow New Preloader (Pro Preloader , Rotate Preloader)
    • Happy New Year , by new Theme (Christmas 2010)
  • Add to Technorati Favorites

    Subscribe
  • Google
    Custom Search

Copyright © 2009 FlashBannerOnline - Powered by Wordpress.

FBO by