DIG2500c_lecture12 - Fall 2009 Semester Dr Rudy McDaniel...

Info iconThis preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon
DIG2500c: Fundamentals of Interactive Design Fall 2009 Semester Dr. Rudy McDaniel Lecture 12: ActionScript Programming: Random and Arrays
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Review from Last Week Functions Randomization
Background image of page 2
This Week New Topics: Arrays Custom Objects Assignment for Homework 2 Labs: Uploading your final project
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Randomization Use to introduce non-predictable states into your interactive designs
Background image of page 4
Math.Random This method of the Math class chooses a random number between 0 and 1 Other useful methods and constants from the Math class [ActionScript Live Reference]
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Choosing Random Numbers Let’s choose a thousand random numbers between zero and one. How would we accomplish this using what we already know about ActionScript so far? Oftentimes, there are multiple ways to accomplish a given task.
Background image of page 6
Non-Optimal Solution The first thing we might try is writing individual Math.random() calls for every single number we wish to generate.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Solution 1: A More Efficient Way
Background image of page 8
Solution 2: Variation of This Remember that we can build equivalent while loops for any for loops .
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Solution 3: Another Variation How does this work with only 2 lines of code?
Background image of page 10
Solution 4: Using No Loops How could you make an efficient version of this without using a for loop or while loop ? This approach requires a more nuanced understanding of what we have learned in regards to the timeline.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Solution 4: Keyframe 1 Each keyframe in this animation will contain different ActionScrip t code.
Background image of page 12
Solution 4: Keyframe 2 Note that the if statement defined in keyframe 2 is handling the logic portion of our task.
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Here, we increment i after each cycle through the animation. Why do we
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/21/2011 for the course DIG 2500 taught by Professor Mcdanial during the Fall '09 term at University of Central Florida.

Page1 / 53

DIG2500c_lecture12 - Fall 2009 Semester Dr Rudy McDaniel...

This preview shows document pages 1 - 15. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online