冒险解谜游戏中文网 ChinaAVG

标题: Flash CS3 内嵌字体教程 [打印本页]

作者: shane007    时间: 2010-1-22 11:33
标题: Flash CS3 内嵌字体教程
本资料用于研究神秘视线6的汉化。1 K+ |% V. H& I" {2 y4 u. I
希望有热心的朋友把它翻译为中文。5 e2 C% T0 t$ u% v* ]% ]

4 }# W! ^) G8 D5 J2 Q7 m" w原文  O. Q& y# A* @; O1 x" D+ o
http://livedocs.adobe.com/flash/ ... ;file=00000895.html
7 a3 S( @5 V5 Z. a' k
7 o, q  [: p. F0 D. @Using TextField methods with embedded fonts% Q, R9 f" k9 u
Methods of the TextField class provide useful functionality for your applications. For example, you can control the thickness of a text field by using ActionScript as demonstrated in the following example. $ H: r/ ~. s* g- [
8 u+ N9 ^& m4 V/ a. M/ g1 g
To set a text field's thickness using ActionScript:9 L2 R! @3 X* F# Q) s# k
Create a new Flash document and save it as textfieldThickness.fla.
( R$ q8 O2 l  @0 m; P2 [Open the Library panel, and select New Font from the pop-up menu (in the upper-right corner of the Library panel). 0 g' b4 d* M9 r1 \! q) Z6 `7 p
The Font Symbol Properties dialog box opens. This dialog box lets you select a font to embed in the SWF file (including a font style and font size). You can also assign a font name that appears in the document's library and the font drop-down menu in the Property inspector (if you have a text field selected on the Stage).6 M3 w$ C& B% b% i7 N, U
3 \; M7 t! [$ K, r" o
Select the Times New Roman font from the Font drop-down menu.
$ ^* }# a4 d  H* K# N- E5 }Make sure that you deselect the Bold and Italic options. - u# F& V6 A3 X+ u1 g% h0 B' S
Set the size to 30 pixels.
' U! G- ~7 [- |) L, iEnter a font name of Times (embedded) " Y( H% @  a$ R2 W; A
Click OK.
+ e3 O2 `6 O' _* MIn the library, right-click the font symbol, and then select Linkage from the context menu. : Q, z% S9 ~3 Z7 N& J" Q9 V# {; W* A
Flash opens the Linkage Properties dialog box.
8 S/ j! y. U( l2 [% g9 }+ L) W" s+ r+ Z0 k6 I( q
Select the Export for ActionScript and Export in first frame options and click OK.
2 ~7 Z( Y+ Z- x" [' ^6 y- n' AAdd the following ActionScript to Frame 1 of the Timeline:
6 N9 I4 Z/ x) d9 v// 1* ~; V. l3 T  `- Y7 X& }$ i5 s
this.createTextField("thickness_txt", 10, 0, 0, Stage.width, 22);
- z, B: R- c2 hthis.createTextField("lorem_txt", 20, 0, 20, Stage.width, 0);
  @1 A2 Y" X9 l& j6 e" T5 |lorem_txt.autoSize = "left";
3 f3 l3 T" _1 N. vlorem_txt.embedFonts = true;
. y8 j7 @1 W: xlorem_txt.antiAliasType = "advanced";
+ K" A% K# @: |/ D4 Y" h  c* tlorem_txt.text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
7 U3 ?5 T& S3 N0 N0 Y/ e% `0 Vlorem_txt.wordWrap = true;& f. y1 k- O' n& G
5 J: {8 J9 i3 K6 T' V! u
// 25 Z# x9 N! U1 a8 G  w
var style_fmt:TextFormat = new TextFormat();" H0 x1 j: ]) @- [7 l! m4 c# @0 q
style_fmt.font = "Times (embedded)";/ v* O+ F. Z* h) }! {9 r8 R
style_fmt.size = 30;  x- o7 J7 @4 A) S! J' s( {
lorem_txt.setTextFormat(style_fmt);
( V4 a) h( _( ^, }6 @8 ]9 u  T! X5 M4 t
// 32 ?- ^. F7 j$ }3 w" j1 c  L
var mouseListener:Object = new Object();. l1 B! |- g" K7 b) ]
mouseListener.onMouseMove = function():Void {
" E4 b9 W+ E5 n0 n) L. ^    // Values for TextField.thickness can range from -200 to +200.
+ ?$ F7 y* K) B& W) C    lorem_txt.thickness = Math.round(_xmouse * (400 / Stage.width) - 200);: K: ~/ g# G( ^, x& }" j
    thickness_txt.text = "TextField.thickness = " + lorem_txt.thickness;
9 U1 i4 ^% b6 E/ ^" l! Y4 {( a};) e& }; ?! j/ z$ E
Mouse.addListener(mouseListener);
& Y* V, v7 M" h9 ^0 B: J. [The first block of code creates two text fields, thickness_txt and lorem_txt, and positions them on the Stage. The lorem_txt text field sets its embedFonts property to true and populates the text field with a block of text.1 ~/ T6 \$ C1 E/ `
& K; F' H/ w0 _5 M
The second block of code defines a text format with the font face Times New Roman, sets the font size to 30 pixels, and applies the text format to the lorem_txt text field.
, j$ S7 H* g, X( }+ R5 P, r/ d+ z5 F2 m. w0 y- f+ X! Q/ p
The third, and final, block of code defines and assigns a mouse listener for the onMouseMove event. When the mouse pointer moves horizontally across the Stage, the TextField.thickness property changes between -200 and +200, depending on the current value of _xmouse.
' C- S0 P) j* B  [" [$ C5 S
5 z3 I& ]; @/ w, USave your changes to the FLA file. $ P7 V0 l4 {0 `) D
Select Control > Test Movie to test your Flash document.
- D# B8 D0 G* C& V  b- Y" zWhen you move the mouse pointer to the left half of the Stage, the font thickness decreases. When you move the mouse pointer to the right half of the Stage, the font thickness increases.




欢迎光临 冒险解谜游戏中文网 ChinaAVG (https://chinaavg.com/) Powered by Discuz! X3.2