本资料用于研究神秘视线6的汉化。
* H% s% s& J9 b; P( P希望有热心的朋友把它翻译为中文。
v3 H6 Q' b+ p" _! ?0 B `
0 k/ V0 V0 [; n6 o原文% B$ @' ], D% p. n. R
http://livedocs.adobe.com/flash/ ... ;file=00000895.html$ `& d5 T# x2 z. b, P- \
* Y- J W& U+ p0 `4 SUsing TextField methods with embedded fonts
' D" H& D. ? J' ]8 I6 MMethods 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.
4 V# ~, P; q- a3 ^6 L' M: h- Q. j7 ^' W8 y; n3 `
To set a text field's thickness using ActionScript:
" Z1 k# D5 L5 ~& C' z9 j+ U P9 t/ {Create a new Flash document and save it as textfieldThickness.fla.
" k. ^, g; }% u, d; k! t5 NOpen the Library panel, and select New Font from the pop-up menu (in the upper-right corner of the Library panel). 4 o% \+ v; M& T& ], n( b
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)./ M- M r: }! _, q; r8 }6 H
# e M! c+ o6 v8 W* X, S( r2 E
Select the Times New Roman font from the Font drop-down menu. * }3 M$ ~/ d& G2 W4 X0 f4 b* G
Make sure that you deselect the Bold and Italic options.
! L6 u4 k4 S' m2 l# T! n' QSet the size to 30 pixels.
. T' }6 V. [' S' Z' VEnter a font name of Times (embedded)
, X! w; R6 O0 v/ w* {Click OK.
$ O2 Q- ^% i4 ]/ _" oIn the library, right-click the font symbol, and then select Linkage from the context menu. * I E7 F" S3 H& h4 x
Flash opens the Linkage Properties dialog box. ; i/ O9 S0 T* q$ {( V+ u1 |7 a
* C+ y4 D0 I+ \
Select the Export for ActionScript and Export in first frame options and click OK.
# t6 I5 [0 `0 ~) ^+ HAdd the following ActionScript to Frame 1 of the Timeline:( `8 ~7 k( T0 a/ T: @
// 11 h" V5 {5 Q$ ]
this.createTextField("thickness_txt", 10, 0, 0, Stage.width, 22);
: z" r9 i, l9 ?3 E0 Z3 s0 r+ [this.createTextField("lorem_txt", 20, 0, 20, Stage.width, 0);9 c% {& O: X ^* D3 x0 r& ?5 U
lorem_txt.autoSize = "left";4 e& {) V$ Q3 |, w* w
lorem_txt.embedFonts = true;
' O3 n, E: q+ F2 Y' S" t/ Y) }lorem_txt.antiAliasType = "advanced";- T% ]. b0 P0 x3 [: q( S0 \" q1 l2 w
lorem_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.";; P8 i0 Y) h9 c& i/ X8 T7 q
lorem_txt.wordWrap = true;' \/ ?$ C8 w h4 h* ~9 w8 a
l# v+ A3 a& c' R1 L; T
// 27 a a& ?1 M3 ^' d) A
var style_fmt:TextFormat = new TextFormat();; D4 g7 o) t5 R
style_fmt.font = "Times (embedded)";3 a. H6 w% `" j9 ]: ~1 d$ r
style_fmt.size = 30;
$ U: X6 W6 p- [3 O5 Nlorem_txt.setTextFormat(style_fmt);/ k4 h# m/ @0 Y) I% S: `
, Q9 \$ U& d8 ~' v+ |2 |
// 3. N( m* [! x; i9 J3 y
var mouseListener:Object = new Object();2 Q2 p- a; |; _3 e9 e) Q: s. ]$ k
mouseListener.onMouseMove = function():Void {0 P( ~* b9 R; |5 T* g5 C0 F- T
// Values for TextField.thickness can range from -200 to +200.- T7 m2 j4 B$ J Y& y5 w
lorem_txt.thickness = Math.round(_xmouse * (400 / Stage.width) - 200);
! ], q- H" ]) G; t: u thickness_txt.text = "TextField.thickness = " + lorem_txt.thickness;/ ] X; k, m8 O! D8 d( x& l1 K+ k
};
S" i [+ R3 o# V) ~Mouse.addListener(mouseListener);
4 Y: {# a; v' L- o: j) F. [# fThe 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.
7 s* q, r; C0 F% @$ H
4 o! R# C% _1 x: }! p jThe 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.0 x' U! T/ ]* }' Z
$ g. S# B" ~/ c* 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.1 ^2 i. p( m; l! h( D9 z+ x) i% g
+ @; i% J( L/ [8 X. kSave your changes to the FLA file.
; P" Z" u& ~% `( _$ g9 y1 |; z8 FSelect Control > Test Movie to test your Flash document.
# ]' n! A$ P( R: o( EWhen 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. |