冒险解谜游戏中文网 ChinaAVG

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

作者: shane007    时间: 2010-1-22 11:33
标题: Flash CS3 内嵌字体教程
本资料用于研究神秘视线6的汉化。
( G$ H. ?0 a6 y1 o& E9 e希望有热心的朋友把它翻译为中文。) R- k. h6 {% f1 }( g7 D
3 X$ L' L4 w. |1 m4 A  s! V' [2 Z
原文& j2 k$ ^* b2 z2 `5 W, l( E
http://livedocs.adobe.com/flash/ ... ;file=00000895.html
; h/ Z, [  e, \7 h) S1 F6 [8 a8 F5 a2 r. d  F' j% `
Using TextField methods with embedded fonts" I' D# w) Q" |" g4 k- P7 s/ f( b
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.
2 T# x) B! _+ o) \8 s9 c
' s& {8 H% ~( f! r* m4 zTo set a text field's thickness using ActionScript:% h, L" W2 \1 l7 ~
Create a new Flash document and save it as textfieldThickness.fla.
) v8 B, ~6 |! }4 l, A7 F6 fOpen the Library panel, and select New Font from the pop-up menu (in the upper-right corner of the Library panel).
9 H/ H$ b  y- }0 \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).4 g% i) W! R+ B+ U
8 k9 B: y1 {7 t, F; i
Select the Times New Roman font from the Font drop-down menu.
% z, B- q  o) f) F5 HMake sure that you deselect the Bold and Italic options.
; g+ f' D3 c3 R' q- ^8 Q3 f* O1 pSet the size to 30 pixels.
- `. b' s1 y* S& ^3 GEnter a font name of Times (embedded) ( n7 x4 y: l; m$ q
Click OK.
) v. [* y& L7 X1 q8 Q- A9 t1 DIn the library, right-click the font symbol, and then select Linkage from the context menu. ( ?) D( N' v! @  O
Flash opens the Linkage Properties dialog box.
! u4 E6 Y: {% b# M3 w, Y7 W$ T9 ?  j- j1 B7 A2 }" C" g
Select the Export for ActionScript and Export in first frame options and click OK. " a" X7 t3 J, [& a" \7 z/ l+ v
Add the following ActionScript to Frame 1 of the Timeline:
4 O* W( O/ t5 Q% y" T// 13 L$ ^1 J" T* l% ]/ U& ^  y2 X
this.createTextField("thickness_txt", 10, 0, 0, Stage.width, 22);  E3 s9 k' T( ~4 e) n! J4 n
this.createTextField("lorem_txt", 20, 0, 20, Stage.width, 0);: F' V) f9 W7 X6 c3 k* Y
lorem_txt.autoSize = "left";1 h4 }0 x/ ^2 a. A! \
lorem_txt.embedFonts = true;
' N, b: V. H, u8 r" {lorem_txt.antiAliasType = "advanced";
, C# v, t* F# a# E5 k4 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.";
6 k, l/ E+ m5 q; y) V+ x3 T4 ~2 mlorem_txt.wordWrap = true;
) g- i* c4 b& s; [& f- z0 i* N0 q3 Q! e: |  O  q! o7 Q3 q
// 2
2 E$ w9 M. d! ]& |# v! svar style_fmt:TextFormat = new TextFormat();# v' E+ R3 F# @. F8 c' _8 ~
style_fmt.font = "Times (embedded)";
& M7 z8 c3 G3 c; z) U  Astyle_fmt.size = 30;  b, \& r/ I' j! K$ O% N% V
lorem_txt.setTextFormat(style_fmt);+ Q% V3 L0 O$ l) w  d, C5 y- l

- w5 i7 _$ h. G& Z// 3
8 I. P! t+ f3 o; Fvar mouseListener:Object = new Object();: H: ~" B1 U! y( u
mouseListener.onMouseMove = function():Void {
) d# T4 m6 j( Z2 ]: y    // Values for TextField.thickness can range from -200 to +200.+ I, O& t$ A$ Z" Z3 a
    lorem_txt.thickness = Math.round(_xmouse * (400 / Stage.width) - 200);
, U1 M. R( X  [) M, F, o$ D2 n    thickness_txt.text = "TextField.thickness = " + lorem_txt.thickness;
" Y& @# t+ j, [9 e0 E& j2 T};; x8 G. @; z# z1 o
Mouse.addListener(mouseListener);
8 a" }- a% O5 u9 cThe 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.% {0 y% u# j1 F- E4 y: p+ V

( S- Z* y+ W# r7 X+ OThe 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.
$ W, |. K4 b9 n" h' f' e
. t+ k7 c  }& }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.
- n) p5 y3 F- \' X3 |) Z: L) e
+ p+ q. \  |( ~Save your changes to the FLA file. : T/ A# Y" d2 V8 \" o3 S6 ~* m! F. a
Select Control > Test Movie to test your Flash document.
- h4 i7 x9 y- _, \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.




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