Understanding Objects

 < Day Day Up > 



Objects are a collection of properties; all properties have a name and a value. Objects have changeable and accessible characteristics that you set by using ActionScript. Objects in Flash have different meanings. There are graphical objects, user-defined objects, and built-in objects. Graphical objects are drawings, photos, or text. The object is not only the image but the instructions that go along with it for its properties and/or methods. For instance a box has properties of height and width.

An instance of a symbol has to be placed on the Stage to have an object action applied to it. Actions are not applied while in Symbol Editing mode. A few of the built-in objects follow.

The Array object

A list of options to choose from is frequently used as a menu and powered by JavaScript. You can do it in Flash using the Array object. The method of the Array object is New Array with an optional argument for array length. For example, you have a customer list with a list of names such as

Name ="Sally"; Name2="Gerald";  Name3="Sue"; Name4="Hank";

A new Array would appear as

customers=New Array(Sally, Gerald, Sue, Hank); message="Thank you for your order" + [3];

The result of this small piece of code is

Thank you for your order Sue. The number 3 indicates that the third  name in the list should be used, which is Sue.

The Color object

The method of the Color object is SetRGB. This sets the color of the color object. The argument is 0XRRGGBB. The zero x (0x) is an escape code for hexadecimal values and is always used prior to the hexadecimal values. You replace the RRGGBB with the hexadecimal values of the color you want to use. You can find the hexadecimal values in the Mixer panel.

There are two ways to manipulate the color attributes of a Movie Clip instance: the hexadecimal value and the RGB code. The RGB values are in decimals from 0 to 255 and translate to 0 to FF in hexadecimal.

Math objects

The math objects access trigonometry functions. All the math objects prepare read-only values and are written in all capital letters. The trigonometry functions of sine, cosine, and tangent, logarithmic, mathematical, and constant are beyond the scope of this book. math.round is just what it sounds like; it rounds to the nearest integer.

You code looks like this:

math.round(this.getBytesTotal()/1000)

This code means to round off the calculation of the objects total size property (this refers to the object you are editing) to the nearest byte giving the total number of kilobytes of the object. The total bytes in this case it will be the size of a movie, which is a song. At the end you add /1000, which tells Flash to divide by 1000, so you get the number of kilobytes instead of bytes.

The Movie Clip object

Movie Clip is one of Flash's predefined objects. Movie Clips can be instances, but they can also be objects. As objects, they have characteristics you can access and control. Some of the properties you have control over include appearance, such as transparency, visible or color, size, and position.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net