Flash Game Design  
 
Flash Tutorials Photoshop Tutorials Flash Games  
Dynamic Text using AS 3
 
Step 1.

In it's most simplest form the following 3 lines of code (a) are needed to create a dynamic text field using Actionscript 3. The 3 lines of code are placed on the first frame of the timeline. The text (b) is displayed with default formatting.

a)   b)
 

Line 1 - Create a TextField object called txt

Line 2 - Add what you want to be displayed, to the text property of the new object

Line 3 - Add the textfield object to the stage. You can also add it to any movieclips you create.

 
Step 2.
So you've now created a text field on the stage, but you'll likely want to position it somewhere else and format it in some way. First of all we'll position the text, 50 pixels along the x and y axis.
a)   b)
 
 
Step 3.
To format the text we need to create a TextFormat object and set some properties. Here is a complete list of the formatting properties.
a)   b)   c)

Line 6 - Create a TextFormat object called format

Line 7 - set the color of "format". I've set it to red but you can set it to any color, by using the code that is produced in the color panel in Flash (c)

Line 8 - Set the font of the text. The default (step 1) is verdana

Line 9 - Set the size of text

Line 10 - Make the text bold

Line 11 - set "format" as the TextFormat of the txt object

 
Dowload Source
 
 
 
   
     
     
 
Navigation
Flash Tutorials
Photoshop Tutorials
Flash Games
War Games
 
 
 
 
 
 
 
Top Flash
Create a Spot the Difference Game
Create a Shooter Game
Flash Gallery Tutorial
Flash Website Tutorial
Flash Glitter Graphic
 
 
 
 
 
 
Game Websites
Happy Wheels
Tower Defense Games
Hunting Games
Mario
 
 
 
 
 
 
 
 
     
Site Copyright © 2006 - 2011 Nick DS. All rights reserved.