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.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...