Home | Flash AS3 Tutorials | Flash Animation Tutorials | Store

Using htmlText Property in Text Field Flash AS 3 Tutorial

Sometimes you may also require to insert some HTML Tags to Text Field of Flash Movie. This Flash ActionScript tutorial shows how to do it.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

In previous Flash ActionScript tutorial, you learned how to insert line break and paragraph break in text Field. Now you may also wish to do some styling with the text Field, for example, insert some HTML tags to the Text Field, e.g. <Font>, <B>, <I>, <U>, etc....

The complete Flash Movie is shown as above, you may try how it works before you start this ActionScript tutorial.

Flash ActionScript Codes:

//Set the multiline parameter of the Text Field to true
//The <br> tag creates a line break in the Text Field.
//Must set the text field to be a multiline Text Field to use this tag.
output_txt.multiline = true;

 

//Allow HTML Property of the TextField
//Apply some HTML tags to texts
output_txt.htmlText = '<font color= "#ff0000">This is the 1st line using Font tag.</font>' + "<br>" +
"<I>This is the 2nd line using Italic tag.</I>" + "<br>" +
"<b>This is the 3rd line using Bold tag.</b>";

Download Flash Source File:

Flash Source File using-htmltext-property-in-textfield.fla

Remarks:

This Flash ActionScript tutorial shows how to insert some HTML tags to the Text Field with htmlText property.