Your SlideShare is downloading. ×
ARTDM 170, Week9: Encapsulation + Paper Prototypes
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

ARTDM 170, Week9: Encapsulation + Paper Prototypes

357
views

Published on

Published in: Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
357
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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
  • 4. Encapsulation
  • 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"); }
  • 11. Paper Prototypes
  • 12. Building Paper Prototypes • Cheap, easy, and effective • Paper Prototyping on A List Apart
  • 13. Arrays
  • 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)