本资料用于研究神秘视线6的汉化。; @1 j6 q3 p" `& ^0 Y2 @/ k
希望有热心的朋友把它翻译为中文。
8 u: k: @7 A, V% D
! A- I! z# c, `" j. }5 v原文
0 y2 g" q. y5 W3 B L7 ^6 N' qhttp://livedocs.adobe.com/flash/ ... ;file=00000895.html
, [0 c3 b* T+ v9 h i7 b, B) O5 e9 u# g0 ]: J# D, ~
Using TextField methods with embedded fonts
# t% y% ?9 r- p x' k- y/ d. GMethods 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. 3 O, `3 K: q6 y# K: x7 S+ ?$ j
6 a q# ]* v) T& C) f0 W
To set a text field's thickness using ActionScript:: b9 \( d% q) j6 W! h9 Y
Create a new Flash document and save it as textfieldThickness.fla.
( Y; n$ |9 j* ?4 d( `( F( uOpen the Library panel, and select New Font from the pop-up menu (in the upper-right corner of the Library panel).
}4 {: P, X) D4 H$ d" w3 e0 }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).
& R) h: R% g; I) V6 O/ g3 q8 j, N4 _0 L8 G6 D
Select the Times New Roman font from the Font drop-down menu. 6 B9 W" e0 T$ I0 N+ k3 ]; N( F( v
Make sure that you deselect the Bold and Italic options. ! b+ s9 n' q* l4 ` O+ `/ S
Set the size to 30 pixels.
7 Q# M# Y$ Q2 |/ z- }8 c( y- mEnter a font name of Times (embedded)
/ |& s- p9 \' \3 f! `Click OK. 4 v6 T' s1 U1 D2 K& i1 l
In the library, right-click the font symbol, and then select Linkage from the context menu. 6 ~& c) `: o2 c! x/ f' E
Flash opens the Linkage Properties dialog box. + s; z J0 [+ T2 Z
* i% L$ }- A8 l) x* A
Select the Export for ActionScript and Export in first frame options and click OK. 0 q$ N4 R9 {5 B/ M1 w% q
Add the following ActionScript to Frame 1 of the Timeline:7 T5 E8 e& J7 Q
// 1
# U# E8 F0 w! a9 s$ i }1 cthis.createTextField("thickness_txt", 10, 0, 0, Stage.width, 22);
+ ^8 P/ q- w* ]8 v# b2 }this.createTextField("lorem_txt", 20, 0, 20, Stage.width, 0);& X/ u# U4 V d H
lorem_txt.autoSize = "left";/ ~; `# A/ O/ o
lorem_txt.embedFonts = true;
7 o c5 q: G1 glorem_txt.antiAliasType = "advanced";* f9 k W; Q, h. z! N* W% n
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.";
l, ^" l- f7 Z3 q2 D9 Zlorem_txt.wordWrap = true;0 ~: a4 h' _2 R0 O: ~$ @1 D
5 C: n: x$ R" q7 ~. c
// 2' K% U( z% j" C; ^$ L2 j9 a* n7 I
var style_fmt:TextFormat = new TextFormat();
4 p5 H0 Q& h" Cstyle_fmt.font = "Times (embedded)";
! [4 O! e' f, D) h. a" t2 o# ostyle_fmt.size = 30;3 y4 X' y/ ?$ b( ]+ ^; n# b/ Y' A1 s
lorem_txt.setTextFormat(style_fmt);
n7 F' ~+ j& }& y, e, `( z0 H0 i9 h, p5 B8 m @
// 3
; {2 U/ y; S6 l4 wvar mouseListener:Object = new Object();& O% R. }2 e3 d& F
mouseListener.onMouseMove = function():Void {, { s3 w: Y0 p3 ?. T/ a
// Values for TextField.thickness can range from -200 to +200.$ g2 D4 Q! c: k( _ f) D" Y' n, }
lorem_txt.thickness = Math.round(_xmouse * (400 / Stage.width) - 200);1 v$ h! \: |! ]5 @1 ~( i' N7 z U+ c
thickness_txt.text = "TextField.thickness = " + lorem_txt.thickness;0 i# ~' i. x5 t# } S, l/ N+ X! l
};
' Y2 l8 K; Q: I3 v5 Y( z. ?Mouse.addListener(mouseListener);+ p0 m; j! t& f i8 G% V
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.
6 \. Y: ^: d1 f/ U
' j0 g7 }! l" J* u eThe 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.+ c; V' v) G: d! [) ~1 ~
. K& v" X1 a" j( x) O& }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.
4 f' C- Q3 ^" d' k3 _! _/ r" n# p1 [% n/ W( H: B( n& ^- q$ a
Save your changes to the FLA file.
* o+ x# H: s# ~4 n6 K9 sSelect Control > Test Movie to test your Flash document. * t! k9 i: n- J
When 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. |