Unit 17.  Introduction to ActionScript (IV)

The Objects


The Objects, as we've already seen in the basic theme, are instances of a certain class. It means that they are representatives of an already defined class.

So, these are objects, to understand it better we will see some examples: a button, a movie clip, a graphic or a sound... or in other words, almost EVERYTHING is an OBJECT in Flash.

We are going to see the most used objects in Flash and a brief description of each one of them.

As it has already been explained in the basic theme, each object has a set of Properties (that we will see later) and some Methods and events, that give functionality to the objects. When a component of Flash turns into an object, automatically it acquires at once all the properties defined by Flash for that object and it responds to the methods and events that it has defined. You can find a list with all the properties, methods and events of the objects in the Panel Actions.


"Button" Object

The objects Button have 4 states, as we have already seen in the corresponding unit and they respond to special methods like "OnRollOver", "OnPress"... that will allow things happen when the user clicks these buttons, passes over them etc...

When we want a designed image behave as a button, it will be enough to convert it into button (like we explained in the corresponding unit) and we'll be already able to use the typical events of a button.

"MovieClip" Object

When we need to create a Flash movie inside of another, but we don't want to have 2 separated files, we will have to create a movieclip object. One of its properties is especially useful and that is that thay have a timeline that runs INDEPENDENTLY from the timeline of the main Flash movie, which allows us to create as complex and independent animations as we want (we can create as many movie clips as we want within others, for example).

"Sound" Object

The sound objects are hidden, and thus, we'll not be able to see how they remain in the frames, similar to what we would make with a button or a movie clip. We'll have to control them, therefore, from the Actions Panel and by using ActionScript. They have multiple special methods, very powerful and useful, we can stop a sound, create a loop, apply sound effects to it etc...

For example, we could create an object of sound type and later make the button reproduce the sound when being pressed. (In the following unit some example of sounds use will be seen).

"Mouse" Object

The object mouse is one of the Flash objects that is already defined by Flash, because it referes to Windows mouse (that the user will handle when seeing our movie). If we use it, we will be able to access the properties of the Windows mouse, associated effects, detection of its position etc...

It is worth underlining that its operation is NOT similar to other objects, because we can create as many objects as we want and do with them what we want, but the object Mouse is unique and it acts indepently of our movie. We can say that it is "an external" object that lets other parts of the Operating system interact with our Flash movie. Therefore, it is very powerful.

"Math" (Mathematics) Object

It is one of the multiple "abstract" objects of Flash, neither it is visual, nor it seems to corresponds to anything existing in the system (like the "Mouse" object). Its function is very important, because it allows us to use mathematics formulas easily. In the following theme we will see some example of its use.

"String" Object

It is another peculiar object, because it corresponds to a data type. Strings are sequences of characters. If we define a sequence of characters like an object of String type, we'll be able to use the methods implemented by Flash: to select subchains of letters, search for a certain letter in a word, format the word characters to uppercase and lowercase etc...

The Properties

The Methods usually are specific in each object, and studying them would require a new complete tutorial, (we recommend to consult the help incorporated in Flash when you have doubts), but there are enough properties of the objects that are common to many of them. We are going to see which ones are the most used and what they represent.

In order to use the properties, it is necessary to enter the object name followed by a point ( . ) and later the property and its value. The properties always begin with a script down ( _ ). Some properties can be written without the name of the object to which they refer ahead, in this case, they will refer to the main movie.


It refers to the opacity object that it affects. The opacity can be defined as the non-transparency. So that 100% of transparency are equivalent to a "0" value of opacity (fully transparency) or a "0" value of alpha (fully opaque).


It is the number of frames in a movie clip instance or in the main movie that the system has loaded in memory. (If it is used without an object name then we obtain the loaded frames of the main movie). It is very useful to create loaders or "preloaders"


It returns the number of frames in a movie clip to which it refers. If no name is used ahead, it returns the number of frames in the current Flash movie. It is also used in the creation of loaders (in the following unit we’ll see these properties)


It returns the object height, in pixels. For example, if we have a movie clip called "Clip1" and we write "Clip1._height" we will get the height of Clip1. In the same way we can change it just by doing: Clip1._height=100; (the height of Clip1 will become 100 pixels)


The property is identical to the previous one, but it returns the width of object, in pixels.


It determines whether the object is visible in our movie or not. If its value is equal to 1, then it is visible, when it is equal to 0, it becomes hidden. It is very useful to make movie parts disappear at certain moments. For example, if we want that while pressing a button disappears the movie clip called "Clip2", we will do this: ....... Clip2._visible = 0; .......


With this property we obtain the x coordinate of an object, relative to the X-axis. It serves to find out the position or to assign it dynamically (during the execution of our Flash movie)


With this property we obtain the y coordinate of an object, relatively to the Y axis. It serves to find out the position or to assign it dynamically (during the execution of our Flash movie).


We will see an example of the use of ActionScript.

First of all, and in order to be able to refer us to a symbol in our movie, we have to give it an instance name (to which we will refer when coding). For this, select the symbol and open the Properties Panel.

Replace the <Instance Name> text for a name chosen by you. The object will be ready to treat it.

Suppose we have a rectangle and we have name it r1, we will write this code (associated to a button) in the Actions Panel to change the width of the former.

		on (release) {



Where r1 is the call to the object, _width is the property we want to change and 350 the new value of the property.


You can test your knowledge by doing:

  Unit 17 Test.


Legal warning: Authorised on-line use only. It is not allowed the use of these courses in companies or private teaching centres.
© aulaClic. All rights reserved. Reproduction in any form whatsoever is prohibited.