home support FAQ resources services partners contact us contact us
 Flash MX Previous  Next  
 Tutorial

About built-in objects

You can use built-in Flash objects to access and manipulate certain kinds of information. Most built-in objects have methods (functions assigned to an object) that you can call to return a value or perform an action. For example, the Date object returns information from the system clock and the Sound object lets you control sound elements in your movie.

Some built-in objects have properties whose values you can read. For example, the Key object has constant values that represent keys on the keyboard. Each object has its own characteristics and abilities that make it useful in a movie.

The built-in Flash objects are divided into four categories within the Objects folder in the Actions panel: Core, Movie, Client/Server, and Authoring.

• The Core objects are also core objects in the ECMA specification on which ActionScript is based. The ActionScript Core objects are Arguments, Array, Boolean, Date, Function, Math, Number, Object, and String.

• The Movie objects are specific to ActionScript. They are Accessibility, Button , Capabilities, Color, Key, Mouse, MovieClip, Selection, Sound, Stage, System, TextField, and TextFormat. • The Client/Server objects are ActionScript objects you can use to communicate between a client and a server. They are LoadVars, XML, and XMLSocket.

• The Authoring objects are for customizing the Flash authoring application. They are CustomActions and Live Preview.

Movie clip instances are represented as objects in ActionScript; their default object class is MovieClip. To change the class of movie clips, see “Creating inheritance” on page 241. You can call built-in movie clip methods just as you would call the methods of any other ActionScript object.

For detailed information on each object, see its entry in the online ActionScript Dictionary in the Help menu.

Using a built-in object

Some built-in Flash objects are top-level objects; you can use the methods and properties of a toplevel object without creating a new instance of the object. For example, to use the methods and properties of the top-level Math object, you use the name of the built-in object followed by the method or property, as in the following:

area = Math.PI * radius * radius;

Other built-in objects, like the Date object, require you to create a new instance of the object to use its methods and properties. You use the new operator with a constructor function to create an object. (A constructor function is a function that creates a new instance of an object.) The ActionScript built-in objects are prewritten constructor functions. When you create a new instance of a built-in object, all the properties and methods of that object are copied into the instance. This is similar to dragging a movie clip from the library to the Stage. For example, the following statement creates a new Date object called currentDate and then calls the getMinutes method: currentDate = new Date();

currentMinute = currentDate.getMinutes();

In the following code, the object c is created from the constructor Color:

c = new Color(this);
Previous  Next  
Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist