SlideShare a Scribd company logo
ARTDM 170, Week 9:
Encapsulation and Paper
      Prototypes
          Gilbert Guerrero
         gguerrero@dvc.edu
 gilbertguerrero.com/blog/artdm-170
Homework

• Please put your files in a folder with
  your last name and first initial
• Put the folder in my dropbox
• Example:
  
   smith-h
  
   
 MyAnimation.swf
         MyProjectDescription.pdf
Open Flash

• Create a new ActionScript 3.0
  document:
  
  
 MyEncap.fla
• Create a new ActionScript file:
  
   
   MyEncap.as
Encapsulation
Intro and Ending Screens

• To encapsulate a movie, use 3 frames
 ‣ 1st frame holds the intro screen and
     a button
 ‣   2nd frame holds the game or movie
 ‣   3rd frame holds a game over screen
     and a restart button
Flash Buttons
To create a button:
• Create a new symbol in the Library
• Symbol type: Button
• In a button, each frame is a button state:
  ‣ Up - no user interaction
  ‣ Over - user mouse hovers over
  ‣ Down - user clicks the button
  ‣ Hit - invisible shape defines whatʼs
    clickable
Encapsulation: Frame 1
In the first frame:
• Add a button to the stage
• Name the instance of the button “play_btn”
• Select the first frame and add this script:
play_btn.addEventListener(MouseEvent.CLICK,startGame);

function startGame(event:MouseEvent) {

	   gotoAndStop("playgame");

}

stop();
Encapsulation: Frame 2
•   Create a second frame
•   In the Properties panel, label the frame
    “playgame”
•   Create a MovieClip symbol in the Library
•   Right click on the symbol to open Properties...
    ‣ Click Export for Animation
    ‣ Enter your movieʼs class name in the class field,
      e.g. MyAnimation
•   Drop an instance of the symbol onto the stage and
    place it at (0,0) in the upper left corner of the
    stage
Encapsulation: Frame 3
In the third frame:
• Add a button to the stage
• Name the instance of the button “replay_btn”
• Select the first frame and add this script:
replay_btn.addEventListener(MouseEvent.CLICK,playAgain);

function playAgain(event:MouseEvent) {
   gotoAndStop("playgame");

}

    In a game, the final frame of the encapsulation
    would be your Game Over screen.
Getting to the third frame
Your encapsulated movie needs to provide a way to load
the third frame.
•       Create a variable in your ActionScript class
    public var bounceCount:Number = 0;

•       Add 1 to the variable each time an event occurs
    bounceCount++;

•       When the variable reaches its limit, send the movie to
        the “gameover” frame (you must refer to the root movie)
    if (bounceCount >= 10000) {
          MovieClip(root).gotoAndStop("gameover");

    }
Paper Prototypes
Building Paper Prototypes

• Cheap, easy, and effective
• Paper Prototyping on A List Apart
Arrays
Storing and Retrieving

• Arrays can be used to store data
  fruits = {“apples”,“oranges”,“bananas”}

• Data can be retrieved from arrays
  using the index numbers
  trace(fruits[0]); //apples
  trace(fruits[1]); //oranges
  trace(fruits[2]); //bananas

  // I like to eat apples and oranges.
  trace("I like to eat "+fruits[0]+" and "+fruits[1]+".");


• More about Arrays next week...
Randomization

• Generate a random number between 0
  and .999999
Math.random()

• Round down using Math.floor and to
  multiply Math.random by a number
  get a random integer between zero and
  your number
//generates integers from 0 to 29
Math.floor(Math.random()*30)
Homework, due Oct 21

• Read Chapter 5: Arrays in the
  ActionScript 3.0 Cookbook, p103-136. 
• Be sure you learn about these
  functions:
 ‣  array.push()
 ‣  array.splice()
 ‣  array.concat()
 ‣  and Looping through an Array (see
    section 5.2)

More Related Content

KEY
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
PDF
If your Champ goes missing
PDF
Pre survery
DOCX
Little bit of scratch
DOCX
More than 100 keyboard shortcuts must read
DOCX
Enable right click
PDF
R&R-WHO-WE-ARE
PPT
Kick off 23 8 2012
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
If your Champ goes missing
Pre survery
Little bit of scratch
More than 100 keyboard shortcuts must read
Enable right click
R&R-WHO-WE-ARE
Kick off 23 8 2012

Viewers also liked (12)

DOCX
LETTER_CLBCELIGIBILITY_NICOLEJINN_MLAWILKINSON
PPT
Lions Club Secretary Responsibilites 2013-2014
PDF
Jornada_centres_innovadors_de_Catalunya
PDF
Tecla Gruppo presentazione
KEY
ARTDM 171, Week 13: Navigation Schemes
PDF
Drugstore market 21 oct 2016
PDF
Fisiopatologia do Câncer de Ovários - Apresentação de artigo - New insights i...
PDF
Patent universiade
PDF
5.disoluciones.
PPTX
Nouvelles mobilités : quel rôle pour la transition énergétique ? Automobil...
LETTER_CLBCELIGIBILITY_NICOLEJINN_MLAWILKINSON
Lions Club Secretary Responsibilites 2013-2014
Jornada_centres_innovadors_de_Catalunya
Tecla Gruppo presentazione
ARTDM 171, Week 13: Navigation Schemes
Drugstore market 21 oct 2016
Fisiopatologia do Câncer de Ovários - Apresentação de artigo - New insights i...
Patent universiade
5.disoluciones.
Nouvelles mobilités : quel rôle pour la transition énergétique ? Automobil...
Ad

Similar to ARTDM 170, Week9: Encapsulation + Paper Prototypes (20)

KEY
Artdm170 Week5 Intro To Flash
PPTX
Apps in a Flash HCI
KEY
ARTDM 170, Week 7: Scripting Interactivity
KEY
ARTDM 170, Week 5: Intro To Flash
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm170 week6 scripting_motion
KEY
Artdm170 Week6 Scripting Motion
KEY
Artdm 170 week15 publishing
PDF
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
PDF
Advanced Action Script
PPTX
How to create a simple image gallery in flash cs5
KEY
Coding Flash : ActionScript(3.0) Tutorial
PPT
DOC
Techno flash workbook session 1
PPTX
Gd - 8th - Web Game Design Using Flash
PPT
Actionscript 3 - Session 2 Getting Started Flash IDE
PPT
Lesson 6 cs5
Artdm170 Week5 Intro To Flash
Apps in a Flash HCI
ARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 5: Intro To Flash
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Artdm170 week6 scripting_motion
Artdm170 Week6 Scripting Motion
Artdm 170 week15 publishing
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
Advanced Action Script
How to create a simple image gallery in flash cs5
Coding Flash : ActionScript(3.0) Tutorial
Techno flash workbook session 1
Gd - 8th - Web Game Design Using Flash
Actionscript 3 - Session 2 Getting Started Flash IDE
Lesson 6 cs5
Ad

More from Gilbert Guerrero (20)

PPTX
Designing for Skepticism and Bright Sunlight
KEY
ARTDM 171, Week 17: Usability Testing and QA
KEY
Artdm 171 week15 seo
KEY
ARTDM 171, Week 14: Forms
KEY
ARTDM 170, Week 13: Text Elements + Arrays
KEY
ARTDM 170, Week 14: Introduction to Processing
KEY
Artdm170 week12 user_interaction
KEY
Artdm 171 Week12 Templates
KEY
ARTDM 171, Week 10: Mood Boards + Page Comps
KEY
ARTDM 171, Week 9: User Experience
KEY
ARTDM 171, Week 7: Remapping Cyberspace
KEY
Artdm171 Week6 Images
KEY
Artdm171 Week5 Css
KEY
Artdm171 Week4 Tags
KEY
Artdm170 Week4 Java Script Effects
KEY
ARTDM 171, Week 3: Web Basics + Group Projects
KEY
ARTDM 170, Week 3: Rollovers
KEY
ARTDM 170, Week 3: Rollovers
KEY
ARTDM 170, Week 2: GIF Animation
KEY
ARTDM 171, Week 2: A Brief History + Web Basics
Designing for Skepticism and Bright Sunlight
ARTDM 171, Week 17: Usability Testing and QA
Artdm 171 week15 seo
ARTDM 171, Week 14: Forms
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 14: Introduction to Processing
Artdm170 week12 user_interaction
Artdm 171 Week12 Templates
ARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 9: User Experience
ARTDM 171, Week 7: Remapping Cyberspace
Artdm171 Week6 Images
Artdm171 Week5 Css
Artdm171 Week4 Tags
Artdm170 Week4 Java Script Effects
ARTDM 171, Week 3: Web Basics + Group Projects
ARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: Rollovers
ARTDM 170, Week 2: GIF Animation
ARTDM 171, Week 2: A Brief History + Web Basics

Recently uploaded (20)

PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Basic Mud Logging Guide for educational purpose
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Structure & Organelles in detailed.
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Business Ethics Teaching Materials for college
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
RMMM.pdf make it easy to upload and study
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
human mycosis Human fungal infections are called human mycosis..pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Basic Mud Logging Guide for educational purpose
TR - Agricultural Crops Production NC III.pdf
01-Introduction-to-Information-Management.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Structure & Organelles in detailed.
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Module 4: Burden of Disease Tutorial Slides S2 2025
Business Ethics Teaching Materials for college
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O7-L3 Supply Chain Operations - ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Anesthesia in Laparoscopic Surgery in India
RMMM.pdf make it easy to upload and study
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx

ARTDM 170, Week9: Encapsulation + Paper Prototypes

  • 1. ARTDM 170, Week 9: Encapsulation and Paper Prototypes Gilbert Guerrero gguerrero@dvc.edu gilbertguerrero.com/blog/artdm-170
  • 2. Homework • Please put your files in a folder with your last name and first initial • Put the folder in my dropbox • Example: smith-h MyAnimation.swf MyProjectDescription.pdf
  • 3. Open Flash • Create a new ActionScript 3.0 document: MyEncap.fla • Create a new ActionScript file: MyEncap.as
  • 5. Intro and Ending Screens • To encapsulate a movie, use 3 frames ‣ 1st frame holds the intro screen and a button ‣ 2nd frame holds the game or movie ‣ 3rd frame holds a game over screen and a restart button
  • 6. Flash Buttons To create a button: • Create a new symbol in the Library • Symbol type: Button • In a button, each frame is a button state: ‣ Up - no user interaction ‣ Over - user mouse hovers over ‣ Down - user clicks the button ‣ Hit - invisible shape defines whatʼs clickable
  • 7. Encapsulation: Frame 1 In the first frame: • Add a button to the stage • Name the instance of the button “play_btn” • Select the first frame and add this script: play_btn.addEventListener(MouseEvent.CLICK,startGame); function startGame(event:MouseEvent) { gotoAndStop("playgame"); } stop();
  • 8. Encapsulation: Frame 2 • Create a second frame • In the Properties panel, label the frame “playgame” • Create a MovieClip symbol in the Library • Right click on the symbol to open Properties... ‣ Click Export for Animation ‣ Enter your movieʼs class name in the class field, e.g. MyAnimation • Drop an instance of the symbol onto the stage and place it at (0,0) in the upper left corner of the stage
  • 9. Encapsulation: Frame 3 In the third frame: • Add a button to the stage • Name the instance of the button “replay_btn” • Select the first frame and add this script: replay_btn.addEventListener(MouseEvent.CLICK,playAgain); function playAgain(event:MouseEvent) { gotoAndStop("playgame"); } In a game, the final frame of the encapsulation would be your Game Over screen.
  • 10. Getting to the third frame Your encapsulated movie needs to provide a way to load the third frame. • Create a variable in your ActionScript class public var bounceCount:Number = 0; • Add 1 to the variable each time an event occurs bounceCount++; • When the variable reaches its limit, send the movie to the “gameover” frame (you must refer to the root movie) if (bounceCount >= 10000) { MovieClip(root).gotoAndStop("gameover"); }
  • 12. Building Paper Prototypes • Cheap, easy, and effective • Paper Prototyping on A List Apart
  • 14. Storing and Retrieving • Arrays can be used to store data fruits = {“apples”,“oranges”,“bananas”} • Data can be retrieved from arrays using the index numbers trace(fruits[0]); //apples trace(fruits[1]); //oranges trace(fruits[2]); //bananas // I like to eat apples and oranges. trace("I like to eat "+fruits[0]+" and "+fruits[1]+"."); • More about Arrays next week...
  • 15. Randomization • Generate a random number between 0 and .999999 Math.random() • Round down using Math.floor and to multiply Math.random by a number get a random integer between zero and your number //generates integers from 0 to 29 Math.floor(Math.random()*30)
  • 16. Homework, due Oct 21 • Read Chapter 5: Arrays in the ActionScript 3.0 Cookbook, p103-136.  • Be sure you learn about these functions: ‣ array.push() ‣ array.splice() ‣ array.concat() ‣ and Looping through an Array (see section 5.2)