Introduction to ActionScript 3.0

11 minutes
Share the link to this page
Copied
  Completed
Web development and Presentations in Flash use Action Script programming to a great extent to control the animation on-screen. In this tutorial, you will get an overview of Adobe Action Script 3.0, the latest revolutionary version of ActionScript.

Transcript

Hello, and welcome to this new video tutorial brought to you by our Roja media. In this video tutorial, we are going to get introduced to the ActionScript in Adobe Flash ActionScript is the programming language, we can create anything exciting and interactive within a flash application using this ActionScript. You can write instructions to control the elements in a flash presentation. In flash, when you open a new document, you always see two options here. One is ActionScript 2.0, which is the older version of ActionScript. It's understanding for syntax and logic is different.

The second option is ActionScript 3.0, which is the newer and advanced version. This is much simpler to understand. So we choose New Flash file with ActionScript three point zero. Before we start with any ActionScript pod, we should be well informed of the flash interface, as well as the actions we intend to create onstage. To create and edit the ActionScript code for an object of frame, there is an action panel in Flash. To display the action panel, go to Window actions, or f9 is the shortcut key for it.

This is the complete action panel. This is the action panel title that changes to button actions, movie clip actions or frame actions depending on what is selected in the flash document. The action panel is divided in three sections. Out of these left top is the control section. This holds a list of ActionScript classes and packages. For example, flash dot display contains the class name movie clip, which is subdivided in events, methods, and properties.

These are also called movie clip events, movie clip methods, and movie clip properties. explode the Methods section and view the list below it. Go to end play, and go to and stop are the types of movie clip methods like method, all other classes are also divided into events, methods and properties. Below it, there is a script navigator. This shows a list of frames or objects that have ActionScript code attached. It helps to find scripted code on any particular frame at any time.

At the right top corner, we see this script assist button. This provides a visual interface for editing scripts. When it is on, you cannot type anything in the scripting area. But what we can do is simply drag and drop the event or property we need to use into this area. Then we get an input box about where we can give the name of the object on which that event should be applied. These object names are the instance names given to the object when they are converted into a movie clip symbol.

Instance names play an important role in this coding. any object we need to play with is converted into a movie clip symbol, and applied with an instance name in the objects Properties panel. Those objects are known by their instance names in the ActionScript. For example, if we type animation underscore MC as the object name in this input box, then this automatically updates the script below in the script panel. And gets highlighted. The above line says input flash dot display dot movie clip.

That means movie clip classes called on here from flash dot display section and plays the method we want to apply on animation underscore MC object. So this scripting was done using script assist. But in our learning phase, we suggest not to use script assist. Manual coding helps us understand each and every class properties and methods in detail. To stop this script assessed method, just click on its button. Now we can type and code here manually as before.

In this written code, we observe some of the text is typed in blue by default, these blue text are the words which are already defined in ActionScript coding These tags are well resolved by the action script. And these reserved words cannot be used as the function name or the variable name. Now, what is a function there are repeated tasks, which are to be used multiple times in the code. So, to save time, all these tasks are wrapped together in a way so that they can be reused at any time in the code. It centralizes the code so that it can be placed in a specific place that can be easily updated. Instead of calling the repetitive code, we just call that function wherever needed.

It performs a collective task in a single place. Variables are the data containers, which allow you to store values that you use in your program. So, these function and variable names are supposed to be blue as those blue text are already defined in coding for some different purpose. Let's see an example. Here we see play is in blue. Below that, let's take a new variable named play.

This play is also displayed in blue. That means, we can write the script, but because of the name, it can show an error in the program output. Coming back to the about code, animation underscore MC is in black, because that word is not defined in ActionScript. By default, that is the instance name of the object on the stage which we applied to it. So it will always remain in black. There are syntaxes in the coding which are supposed to be written in the same way as given, like here, go to and play.

If we type the same way, it is shown In the control panel, it turns into blue. But by mistake, if we type p or any single letter in a different case, the ActionScript will not recognize that code and will not work out that way. So, whenever we are writing the code manually, we have to take care that the methods, events and properties texts turn to blue. If not, that means there is some case or spelling error in it, which is to be taken care of. Here. Again, if we change this into a capital P, it will turn into blue text.

Now, let's go through all the tabs available on top of the script window starting from the right most first is apply line or inline command. We can add any single line command in the code which will not be the part of the code This is rather free text that usually either explains parts of the code or communicates something about its purpose. Any of the written code can also be put as a line command, then this part of the code is always available in the code but not executed when complied. It gets ignored by the complier. The comment always begins with two forward slash characters and continues until the end of the line. Now, we don't want this code to be aligned comment, select it, and click on another option available remove command.

So, instead of deleting any of the codes from the script, we can put it in the line command and make it available at any time when we need. Besides that, there is one more option such as apply block command. It is also called as multi line command. meant a number of lines can be selected and put in this block command. You see it starts and ends with the characters, one forward slash and a star. None of them will be read by the complier.

Therefore, anything else can be also written here. Besides that there is collabs between braces. For this. Let's create an example. We write any function here and then below that between the curly brackets for the time being type, any dummy code text. Keep the cursor head between the curly brackets and click on collapse between braces this time hides the text between a set of curly braces.

We can explore it anytime we want. Now, we select all the text here and click on this button collapse selection. It hides all the selected part. If we select any of such section and hold down the Alt key, when we click on this button, all the actions in this panel will collapse, but not the selected code. To display all the collapse codes, you can turn on this expand all button or even click on this plus sign to expand the code. We add play action here.

Now, if we select that area and click on auto format, it formats our script, making it easier to read. Besides that, there is a check syntax option. This checks the current action for syntax errors. Like if we click On this, it shows this script contains no errors. So ActionScript mainly consists of writing code, which is a combination of data commands that modify the data and decisions about what commands to execute. These are some of the basics that you need to know before you start with the ActionScript part.

You can write instructions to control the elements in Flash. Always practice to keep your ActionScript code in a single layer at the top of the timeline that holds only code. To know more, you can go through out of media's videos, which are mainly created for ActionScript 3.0. Hope you found the introduction informative. Thank you for watching.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.