Table of Contents## Chapter 11. Manipulating Information

Entire Site

The information that you store in variables, modify in expressions, and test with conditional statements often needs to be processed and manipulated using mathematical functions such as square roots, sines, cosines, or exponents. Flash can perform these calculations with the Math object, which lets you create formulas for complicated interactions between the objects in your movie and your viewer or for sophisticated geometry in your graphics. For example, the Math object allows you to model the correct trajectory of colliding objects or the effects of gravity for a physics tutorial, calculate probabilities for a card game, or generate random numbers to add unpredictable elements in your movie. Much of this information you manipulate sometimes needs to be stored in arrays to give you better control over your data and a more efficient way to retrieve it. You can use arrays to keep track of ordered data such as shopping lists, color tables, or scorecards.

When the information you need depends on the time or the date, you can use the Date object to retrieve the current year, month, or even millisecond. Build clocks and timers to use inside your Flash movie, or send the time information along with a viewer's profile to a server-side script.

All of this information handling and processing is made easier with the use of functions. You'll learn how to build functions that string together separate action statements and objects to extend their predefined capabilities. Build a single function, for example, that automatically attaches a sound, plays it, and adjusts the volume level and pan settings based on the parameters you provide. You can even build functions to customize your own objects. Extend the capabilities of predefined Flash objects by creating your own methods and properties for your customized objects. This chapter explores the variety of ways you can manipulate information with added complexity and flexibility and shows how to integrate the objects you've learned about in previous chapters.