okgosu의 액션스크립트 정석 - 제1강 - 스타워즈 자막 이펙트

[구현원리]
1) TextField를 담는 Sprite클래스를 x축 방향으로 -70도 회전하여 y축으로 -3정도씩 계속 움직이면 스타워즈 자막이 화면위로 비스듬히 올라가는 이펙트를 구현할 수 있다.
2) TextFiled는 여러줄에 표시되도록 multiline속성을 true, 줄바꿈이 되도록 wordWrap속성을 true, 자동으로 정렬되도돌 autoSize는 left로 지정한다. (자세한 내용은 액션정석 7장 참조)
3) TextField에 스타워즈에 사용된 폰트 효과를 주기 위해 TextFormat을 지정한다. 
4) 엔터프레임 핸들러를 추가하여 TextField를 y축으로 -3씩 감소시키면 자막이 올라간다. (자세한 내용은 액션정석 10장 참조)
1.jpg
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
    [SWF(width=800, height=600,backgroundColor=0x000000)]
public class AsExamStarwars extends Sprite {
public function AsExamStarwars() {
var sp:Sprite = new Sprite();
            sp.x = 100;
            sp.y = 400;
            sp.rotationX = -70;

var tf:TextField=new TextField();
tf.width=600;
tf.multiline=true;
tf.wordWrap=true;
tf.autoSize= "left";
tf.text= "okgosu의 액션스크립트 정석 The Art of ActionScript Coding Flash Game / Flash & Flex Component / Script Motion / Bitmap Graphics / 3D Graphics / Multi Media & Server Interaction okgosu의 액션스크립트 정석 The Art of ActionScript Coding Flash Game / Flash & Flex Component / Script Motion / Bitmap Graphics / 3D Graphics / Multi Media & Server Interaction okgosu의 액션스크립트 정석 The Art of ActionScript Coding Flash Game / Flash & Flex Component / Script Motion / Bitmap Graphics / 3D Graphics / Multi Media & Server Interaction okgosu의 액션스크립트 정석 The Art of ActionScript Coding Flash Game / Flash & Flex Component / Script Motion / Bitmap Graphics / 3D Graphics / Multi Media & Server Interaction";

var txf:TextFormat=new TextFormat("Arial",42,0xE3EF7D,true,null,null,null,null,"justify");
tf.setTextFormat(txf);
sp.addChild(tf);            
this.addChild(sp);
this.addEventListener(Event.ENTER_FRAME, function(event:Event):void{ tf.y-=3;});
}
}
}


profile