SlideShare a Scribd company logo
1 of 20
Action Script Flash
ActionScript คืออะไร
   ภาษาที่ใช้ในการควบคุมการทำางานของวัตถุต่าง
    ๆ ให้มประสิทธิภาพในการทำางานสูงขึ้น นอก
          ี
    เหนือจากความสามารถของโปรแกรม
องค์ประกอบของ 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
                                      }
องค์ประกอบของ ActionScript

       คือ สิ่งที่เกิดขึ้นระหว่างที่ Movie ทำางาน ซึ่งมี
    Event
    ผลทำาให้สคริปต์เหล่านั้นทำางาน ตัวอย่าง Event
    on(release)

        on (release) {
          light.gotoAndStop ("Off");
          message.text = "";
        }
องค์ประกอบของ ActionScript
   แอกชัน (Action) เป็นส่วนที่สั่งให้ Flash ทำา,สร้าง,
            ่
    ตั้งค่า,เปลี่ยน,โหลด หรือลบบ้างสิ่งบางอย่าง
    เช่น
       mugCost = 5.00;
       CashRegister.gotoAndPlay(50);
       light.gotoAndStop ("Off");
       message.text = "";
องค์ประกอบของ ActionScript
   Dot Syntax

    ใช้จุด(.) แสดง Target path ของ Timeline เช่น
              _root.objmain.subobj.obj
     ใช้จุด(.)เพื่อเป็นการกำาหนด Properties หรือ
    Methods ให้กับวัตถุที่แสดงอยู่ใน Timeline เช่น

                 wheel._rotation = 90;
                 wheel.play();
องค์ประกอบของ ActionScript
   Comments       ใช้เครื่องหมาย   Slash   // เช่น
    on (press) {
    amountPaid = Number(paid.text); //แปลงค่าตัวเลข
    amountOwed = Number(owed.text);
    if (amountPaid < amountOwed) {     // ตรวจสอบค่าตัว
    แปร
         difference = amountOwed - amountPaid;
                              :
การประกาศตัวแปร
รูปแบบ
Var variableName:DataType;

เช่น
Var hello:String;
Var i:Number;
Word = “Hello Flash”;
ชนิดของตัวแปร
 Number
 String
 Boolean
 undefined
 null
Expression and Textfield
 Operator ได้แก่ +,-,*,/,%,++,--
 Operator เปรียบเทียบ ได้แก่

  ==,    !=,<>,            <,       >,
  <=,    >=,               ===      !===
 Operator ตรรกะ    ได้แก่
  && AND , || OR, ! not
Keywords


           คือคำาสงวนที่เราไม่ควรนำาไปตั้งชื่อ
    Keywords
    ตัวแปรหรือฟังก์ชั่นเช่น
     break
     else
     on
     typeof
     for
Control Structure
 คำ่าสั่ง IF
 รูปแบบ
       if(condition)
       {
              ……
       }else if(condition)
       {      ……        }
ตัวอย่าง
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;
   }
}
การสุ่มตัวเลข
var answer:Number;
answer=Math.floor(Math.random()*10);
stop();
คำาสั่งการวนซำ้า
   while
    while(condition){
                        statement;
                    }
   do while
   for
     for(int i;condition;next)
                     {
                         statement;
                       }
การวางแผนเขียนโปรแกรมด้วย
Flash
 คุณต้องการให้เกิดอะไรขึ้น ?
 ข้อมูลส่วนใดที่ต้องการติดตาม
 สิงที่ตองเกิดขึ้นใน Movie เมื่อมีการทำาให้
    ่    ้
  สคริปต์ทำางาน
 Event ไหนที่จะทำาให้สคริปต์หลักทำางาน
การใช้ Event ของเมาส์

    on (press)  คือการสัมผัสหรือกดไปบนวัตถุ

    on(release) คือการปล่อยปุมที่กดลงไป
                                ่

    on(releaseOutside) คือการดึงและการ Snap

    on(keypress)คือการใช้คีย์บอร์ด

    on(rollover) คือการใช้เมาส์อยู่เหนือวัตถุแต่ยังไม่
    กดวัตถุนั้น

    on(rollout) คือการเลื่อนเมาส์ออกจากวัตถุ

    on(dragOver) คือการคลิกลากอยู่ภาพในวัตถุ

    on(dragOut) คือการคลิกแล้วลากออกจากวัตถุ
การใช้ Clip Event
   คือ เหตุการณ์ (Event) ที่จะเกิดขึ้นเมื่อ Movie
    Clip เข้าหรือออกจาก Scene
        When this happens (EventsHandler) {
             do this;
             do this;
         }
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) คือเหตุการณ์ของการโหลดข้อมูล
ออปเจ็กต์อาร์เรย์
เป็นที่เก็บข้อมูลที่มากกว่า 1 ข้อมูล โดยมีรูปแบบ
 ดังนี้
    cakeType = new Array();
     cakeType[0] = “Chocolate”;
    cakeType[1] = “Angel Food”;
    cakeType[2] = “Baked Alaska”;

More Related Content

Viewers also liked

Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...
Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...
Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...Thierry Brusselle
 
Swot analysis style 2 powerpoint presentation templates
Swot analysis style 2 powerpoint presentation templatesSwot analysis style 2 powerpoint presentation templates
Swot analysis style 2 powerpoint presentation templatesSlideTeam.net
 
Analisis SWOT Ikan Cupang
Analisis SWOT Ikan CupangAnalisis SWOT Ikan Cupang
Analisis SWOT Ikan CupangNida Chofiya
 
How to do a useful swot analysis
How to do a useful swot analysisHow to do a useful swot analysis
How to do a useful swot analysisKatie Underhill
 
A presentation on swot analysis
A presentation on swot analysisA presentation on swot analysis
A presentation on swot analysisDebajit Ghosh
 
Analisis SWOT untuk Penyusunan Strategi
Analisis SWOT  untuk Penyusunan StrategiAnalisis SWOT  untuk Penyusunan Strategi
Analisis SWOT untuk Penyusunan StrategiDadang Solihin
 
Swot Analysis Template
Swot Analysis TemplateSwot Analysis Template
Swot Analysis TemplateSlideRocket
 
Interactive Teaching Techniques & SWOT Analysis
Interactive Teaching Techniques & SWOT AnalysisInteractive Teaching Techniques & SWOT Analysis
Interactive Teaching Techniques & SWOT Analysism nagaRAJU
 
How to Write a SWOT Analysis Report
How to Write a SWOT Analysis ReportHow to Write a SWOT Analysis Report
How to Write a SWOT Analysis Reportcfdmaster
 

Viewers also liked (20)

Analisis SWOT
Analisis SWOTAnalisis SWOT
Analisis SWOT
 
Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...
Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...
Complete SWOT Analysis (with Leverage, Constraints, Vulnerabilities, and Prob...
 
Swot Analysis
Swot AnalysisSwot Analysis
Swot Analysis
 
Analisa swot
Analisa swotAnalisa swot
Analisa swot
 
Swot analysis style 2 powerpoint presentation templates
Swot analysis style 2 powerpoint presentation templatesSwot analysis style 2 powerpoint presentation templates
Swot analysis style 2 powerpoint presentation templates
 
Analisis SWOT Ikan Cupang
Analisis SWOT Ikan CupangAnalisis SWOT Ikan Cupang
Analisis SWOT Ikan Cupang
 
SWOT ANALYSIS
SWOT ANALYSISSWOT ANALYSIS
SWOT ANALYSIS
 
How to do a useful swot analysis
How to do a useful swot analysisHow to do a useful swot analysis
How to do a useful swot analysis
 
SWOT Analysis
SWOT AnalysisSWOT Analysis
SWOT Analysis
 
Contoh swot
Contoh swotContoh swot
Contoh swot
 
A presentation on swot analysis
A presentation on swot analysisA presentation on swot analysis
A presentation on swot analysis
 
Analisis swot oke
Analisis swot okeAnalisis swot oke
Analisis swot oke
 
Analisis SWOT untuk Penyusunan Strategi
Analisis SWOT  untuk Penyusunan StrategiAnalisis SWOT  untuk Penyusunan Strategi
Analisis SWOT untuk Penyusunan Strategi
 
Swot Analysis Template
Swot Analysis TemplateSwot Analysis Template
Swot Analysis Template
 
Self analysis
Self analysisSelf analysis
Self analysis
 
SWOT Analysis
SWOT AnalysisSWOT Analysis
SWOT Analysis
 
SWOT Analysis
SWOT AnalysisSWOT Analysis
SWOT Analysis
 
Interactive Teaching Techniques & SWOT Analysis
Interactive Teaching Techniques & SWOT AnalysisInteractive Teaching Techniques & SWOT Analysis
Interactive Teaching Techniques & SWOT Analysis
 
Personal swot analysis
Personal swot analysisPersonal swot analysis
Personal swot analysis
 
How to Write a SWOT Analysis Report
How to Write a SWOT Analysis ReportHow to Write a SWOT Analysis Report
How to Write a SWOT Analysis Report
 

Similar to Uj1udqos8e6ljrab9nis9vott3 (14)

Java script 1
Java script 1Java script 1
Java script 1
 
05 loops
05 loops05 loops
05 loops
 
C lang
C langC lang
C lang
 
Dw ch05 basic_php
Dw ch05 basic_phpDw ch05 basic_php
Dw ch05 basic_php
 
Chapter 05 Loop
Chapter 05 LoopChapter 05 Loop
Chapter 05 Loop
 
Chapter 05 Loop
Chapter 05 LoopChapter 05 Loop
Chapter 05 Loop
 
power point.
power point.power point.
power point.
 
207
207207
207
 
Tec4
Tec4Tec4
Tec4
 
Java Programming: โครงสร้างควบคุม
Java Programming: โครงสร้างควบคุมJava Programming: โครงสร้างควบคุม
Java Programming: โครงสร้างควบคุม
 
Scripts 1
Scripts 1Scripts 1
Scripts 1
 
05 Loops
05  Loops05  Loops
05 Loops
 
KMUTNB - Internet Programming 7/7
KMUTNB - Internet Programming 7/7KMUTNB - Internet Programming 7/7
KMUTNB - Internet Programming 7/7
 
PHP Tutorial (introduction)
PHP Tutorial (introduction)PHP Tutorial (introduction)
PHP Tutorial (introduction)
 

Uj1udqos8e6ljrab9nis9vott3

  • 2. 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
  • 12. Control Structure  คำ่าสั่ง IF  รูปแบบ if(condition) { …… }else if(condition) { …… }
  • 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; }
  • 16. การวางแผนเขียนโปรแกรมด้วย Flash  คุณต้องการให้เกิดอะไรขึ้น ?  ข้อมูลส่วนใดที่ต้องการติดตาม  สิงที่ตองเกิดขึ้นใน Movie เมื่อมีการทำาให้ ่ ้ สคริปต์ทำางาน  Event ไหนที่จะทำาให้สคริปต์หลักทำางาน
  • 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) คือเหตุการณ์ของการโหลดข้อมูล
  • 20. ออปเจ็กต์อาร์เรย์ เป็นที่เก็บข้อมูลที่มากกว่า 1 ข้อมูล โดยมีรูปแบบ ดังนี้ cakeType = new Array(); cakeType[0] = “Chocolate”; cakeType[1] = “Angel Food”; cakeType[2] = “Baked Alaska”;