EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 413

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
About font rendering and anti-alias text 413
8. Select Frame 1 of the main Timeline, and add the following ActionScript in the
Actions panel:
import flash.text.TextRenderer;
var arialTable:Array = new Array();
arialTable.push({fontSize:16.0, insideCutoff:0.516,
outsideCutoff:0.416});
arialTable.push({fontSize:32.0, insideCutoff:2.8, outsideCutoff:-2.8});
TextRenderer.setAdvancedAntialiasingTable("Arial", "bolditalic", "dark",
arialTable);
var my_fmt:TextFormat = new TextFormat();
my_fmt.align = "justify";
my_fmt.font = "Arial-embedded";
my_fmt.size = 32;
this.createTextField("my_txt", 999, 10, 10, Stage.width-20,
Stage.height-20);
my_txt.antiAliasType = "advanced";
my_txt.embedFonts = true;
my_txt.multiline = true;
my_txt.setNewTextFormat(my_fmt);
my_txt.sharpness = 0;
my_txt.thickness = 0;
my_txt.wordWrap = true;
var lorem_lv:LoadVars = new LoadVars();
lorem_lv.onData = function(src:String):Void {
if (src != undefined) {
my_txt.text = src + "\n\n" + src;
} else {
trace("error downloading text file");
}
};
lorem_lv.load("http://www.helpexamples.com/flash/lorem.txt");
The preceding code is separated into four sections. The first section of code imports the
TextRenderer class and defines a new anti-aliasing table for two different sizes of the Arial
font. The second section of code defines a new TextFormat object, which you use to apply
text formatting to the text field (that you create in the next section of code). The next
section of code creates a new text field with a
my_txt instance name, enables advanced
anti-aliasing, applies the text format object (created earlier), and enables multiline text and
word wrapping. The final block of code defines a LoadVars object that you use to load text
from an external text file, and populate the text field on the Stage.
9. Select Control > Test movie to test the Flash document.

Table of Contents

Related product manuals