More Related Content Similar to Uj1udqos8e6ljrab9nis9vott3 Similar to Uj1udqos8e6ljrab9nis9vott3 (14) Uj1udqos8e6ljrab9nis9vott32. ActionScript คืออะไร
ภาษาที่ใช้ในการควบคุมการทำางานของวัตถุต่าง
ๆ ให้มประสิทธิภาพในการทำางานสูงขึ้น นอก
ี
เหนือจากความสามารถของโปรแกรม
3. องค์ประกอบของ ActionScript
on (release)
Event {
Action light.gotoAndStop ("Off");
Operators message.text = “Hello”;
Keywords }
Data on (press)
ปีกกา(Curly Braces) {
Semicolons
amountPaid = Number(paid.text);
Dot Syntax
amountOwed =
วงเล็บ(Parentheses) Number(owed.text);
เครื่องหมายคำาพูด(Quotation Marks)
if (amountPaid < amountOwed) {
Comments
.................
Indentation/Spacing
}
4. องค์ประกอบของ ActionScript
คือ สิ่งที่เกิดขึ้นระหว่างที่ Movie ทำางาน ซึ่งมี
Event
ผลทำาให้สคริปต์เหล่านั้นทำางาน ตัวอย่าง Event
on(release)
on (release) {
light.gotoAndStop ("Off");
message.text = "";
}
5. องค์ประกอบของ ActionScript
แอกชัน (Action) เป็นส่วนที่สั่งให้ Flash ทำา,สร้าง,
่
ตั้งค่า,เปลี่ยน,โหลด หรือลบบ้างสิ่งบางอย่าง
เช่น
mugCost = 5.00;
CashRegister.gotoAndPlay(50);
light.gotoAndStop ("Off");
message.text = "";
6. องค์ประกอบของ ActionScript
Dot Syntax
ใช้จุด(.) แสดง Target path ของ Timeline เช่น
_root.objmain.subobj.obj
ใช้จุด(.)เพื่อเป็นการกำาหนด Properties หรือ
Methods ให้กับวัตถุที่แสดงอยู่ใน Timeline เช่น
wheel._rotation = 90;
wheel.play();
7. องค์ประกอบของ ActionScript
Comments ใช้เครื่องหมาย Slash // เช่น
on (press) {
amountPaid = Number(paid.text); //แปลงค่าตัวเลข
amountOwed = Number(owed.text);
if (amountPaid < amountOwed) { // ตรวจสอบค่าตัว
แปร
difference = amountOwed - amountPaid;
:
10. Expression and Textfield
Operator ได้แก่ +,-,*,/,%,++,--
Operator เปรียบเทียบ ได้แก่
==, !=,<>, <, >,
<=, >=, === !===
Operator ตรรกะ ได้แก่
&& AND , || OR, ! not
11. Keywords
คือคำาสงวนที่เราไม่ควรนำาไปตั้งชื่อ
Keywords
ตัวแปรหรือฟังก์ชั่นเช่น
break
else
on
typeof
for
13. ตัวอย่าง
on (release) {
if(Number(userAnswer.text)==answer) {
resultMsg.text="You're Correct !";
} else if(Number(userAnswer.text)>answer) {
resultMsg.text="Answer is less than "+userAnswer.text;
} else if(Number(userAnswer.text)<answer) {
resultMsg.text="Answer is greater than "+userAnswer.text;
}
}
15. คำาสั่งการวนซำ้า
while
while(condition){
statement;
}
do while
for
for(int i;condition;next)
{
statement;
}
17. การใช้ Event ของเมาส์
on (press) คือการสัมผัสหรือกดไปบนวัตถุ
on(release) คือการปล่อยปุมที่กดลงไป
่
on(releaseOutside) คือการดึงและการ Snap
on(keypress)คือการใช้คีย์บอร์ด
on(rollover) คือการใช้เมาส์อยู่เหนือวัตถุแต่ยังไม่
กดวัตถุนั้น
on(rollout) คือการเลื่อนเมาส์ออกจากวัตถุ
on(dragOver) คือการคลิกลากอยู่ภาพในวัตถุ
on(dragOut) คือการคลิกแล้วลากออกจากวัตถุ
18. การใช้ Clip Event
คือ เหตุการณ์ (Event) ที่จะเกิดขึ้นเมื่อ Movie
Clip เข้าหรือออกจาก Scene
When this happens (EventsHandler) {
do this;
do this;
}
19. Clip Event
onClipEvents (load) คือ เหตุการณ์เมื่อทำาการ load Movie Clip
เข้ามา
onClipEvents(unload) คือ เหตุการณ์เมื่อทำาการ load Movie
Clip ออกไป
onClipEvents(enterFrame) คือ เหตุการณ์เมื่อเข้ามายัง
Frame
onClipEvents(mouseMove) คือ เหตุการณ์การเคลื่อนที่ของ
Mouse
onClipEvents(mouseDown),(mouseUp),(keyDown),(keyUp) คือ
เหตุการณ์ของการกดหรือปล่อยปุ่มเมาส์หรือแป้นพิมพ์
ใช้กรณีทำาคีย์ลัด
onClipEvents(data) คือเหตุการณ์ของการโหลดข้อมูล