วันพฤหัสบดีที่ 11 สิงหาคม พ.ศ. 2554

Flash Actionscript Text Animation ตัวหนังสือวิ่งตามเมาส์



Actionscript Text Animation
เป็น Animation ของตัวอักษรที่วิ่งตามเมาส์ วิ่งตามมาทีละตัวค่ะ ลองทำกันดูนะค่ะไม่ยากเลยนะ ใครอยากรู้ว่าทำอย่างไรมาลองทำตามเลยนะค่ะ

ตัวอย่าง Text Animation


1.เปิดโปรแกรม flash ขึ้นมา พร้อมทั้งสร้างเอกสารใหม่ขนาด

Flash Actionscript



2. กำหนดค่าตามรูปนะค่ะ









Flash Actionscript
3. เรียกรูปพื้นหลังมาใส่ใน stage โดยไปที่ File > import > import to stage.. และก็นำรูปที่ต้องการนำมาทำเป็น backgroundมา














Actionscript Text Animation
4. สร้างเลเยอร์ใหม่ขึ้นมา











Flash Actionscript
5 ไปที่เฟรมแรกของเลเยอร์ใหม่ที่สร้างขี้น กด F9 เพื่อเรียก panel Actions ออกมา จากนั้นก็ใส่โค๊ดนี้ลงไป
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Text = "www.sadung.com";
letters = Text.split("");
letterformat = new TextFormat();
letterformat.font = "Arial";
letterformat.align = "center";
letterformat.size = "17";
letterformat.color = 0x92103f;
letterformat.bold = true;
spacing = 6;
speed = 4;
for (var LTR = 0; LTR
mc = _root.createEmptyMovieClip(LTR+"l", LTR);
mc.createTextField(letters[LTR]+"t", LTR, LTR*spacing, 10, 20, 20);
with (mc[letters[LTR]+"t"]) {
text = letters[LTR];
setTextFormat(letterformat);
selectable = false;
}
if (LTR) {
mc.prevClip = _root[(LTR-1)+"l"];
mc.onEnterFrame = function() {
this._x += (this.prevClip._x-this._x+5)/speed;
this._y += (this.prevClip._y-this._y)/speed;
};
} else {
mc.onEnterFrame = function() {
this._x += (_root._xmouse-this._x+10)/speed;
this._y += (_root._ymouse-this._y)/speed;
};
}
}
ข้อความที่ต้องการแสดง ให้เปลี่ยนตรงนี้เลยค่ะ
Text = “www.sadung.com”;
ค่าที่เปลี่ยนได้ ตรง
letterformat….. แปลตรงตัวเลยค่ะลองเปลี่ยนดูนะค่ะตั้งแต่ บรรทัดที่ 1-10

แหล่งอ้าอิง  http://www.sadung.com/?p=4582

ไม่มีความคิดเห็น:

แสดงความคิดเห็น