DIG2500c_lecture12

# DIG2500c_lecture12 - Fall 2009 Semester Dr Rudy McDaniel...

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

DIG2500c: Fundamentals of Interactive Design Fall 2009 Semester Dr. Rudy McDaniel Lecture 12: ActionScript Programming: Random and Arrays

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

View Full Document
Review from Last Week Functions Randomization

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

View Full Document
Randomization Use to introduce non-predictable states into your interactive designs
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]

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

View Full Document
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.
Non-Optimal Solution The first thing we might try is writing individual Math.random() calls for every single number we wish to generate.

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

View Full Document
Solution 1: A More Efficient Way
Solution 2: Variation of This Remember that we can build equivalent while loops for any for loops .

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

View Full Document
Solution 3: Another Variation How does this work with only 2 lines of code?
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.

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

View Full Document
Solution 4: Keyframe 1 Each keyframe in this animation will contain different ActionScrip t code.
Solution 4: Keyframe 2 Note that the if statement defined in keyframe 2 is handling the logic portion of our task.

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

View Full Document
Here, we increment i after each cycle through the animation. Why do we
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
Ask a homework question - tutors are online