Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Set Text Format to TextField with Flash ActionScript 3

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

In this flash tutorial, we will set some Text Formats (e.g. Text Size, Text Color, Bold, Italic, etc..) to the newly created Text Field object with Flash ActionScript 3. The final result is shown as above.

Flash ActionScript Codes:

///////////////////////////////////////////
///// Create New TextField /////
//////////////////////////////////////////

// Create a textfield object with the name "textField_txt"
var textField_txt:TextField = new TextField();

// Add the new textfield_txt instance to the stage
addChild(textField_txt);

// Add Content to TextField
textField_txt.text = "Hello World";

 

////////////////////////////////////////////
///// Set BASIC Properties /////
///////////////////////////////////////////

// Set position of TextField (x = Left, y = Top)
textField_txt.x = 150;
textField_txt.y = 200;

// Set width of Text Field
textField_txt.width = 350;

 

//////////////////////////////////////////
///// Set Other Properties /////
/////////////////////////////////////////

// Text not selectable
textField_txt.selectable = false;

// Text border
textField_txt.border = false;

// Autosize with the text and align to the left.
textField_txt.autoSize = TextFieldAutoSize.LEFT;


///////////////////////////////////////////////
///// Set Text Styling Format /////
//////////////////////////////////////////////

// Create a TextFormat instance (myFormat)
var myFormat:TextFormat = new TextFormat();

// Text size
myFormat.size = 50;

// Text color (hex decimal color code)
myFormat.color = 0xCC0000;

// Set to Italic font
myFormat.italic = true;

// Set to Bold
myFormat.bold = true

///// Set the Format now /////
textField_txt.setTextFormat(myFormat);

Download Flash Source File:

Flash Source File hello-world-again-3.fla

Remarks:

This is the end of the second series of Flash ActionScript 3 tutorial.