In this tutorial, I will briefly go over some basic actionscript commands/functions; I will explain how to use them in this order:
- Declaring variables
- getURL
- trace
- _visible
- Mouse visibility
- _x, _y
- Alpha
- Keyboard interaction
- Play and stop
- Conditional statements
- Loops
- Comments
Declaring variables
Variables are used for many things like interactivity, music, score etc.

Number is self-explanatory. Boolean is a variable with only 2 values, true or false. A string is a series of characters (e.g. “You have won”). Variables do not have to have a preset assignment; you can have it to no value like this:

The above variables do not have defined values.
getURL
getURL, as the name suggests, navigates the default browser to the desired URL. To use it, type this in the actionscript area:

You do not have to have a directly written URL in the URL parameter; you could link it with a string like this:

The above code will also open up google.com, you MUST use the http://
trace
trace is often used for testing purposes and is only visible in the output window. This piece of code will display “Hello” in the output when testing your flash document:

Also, a variable can be placed in the parameter section:

This will give the message: “Hello, my name is Harry”.
_visible
_visible is for, as the name suggests, the visibility of your symbol. It can be set on either true or false:

By default, all symbols are visible unless you specify otherwise.
Mouse visibility
As I showed you in my last tutorial, Mouse.hide(); will hide the mouse from the screen. The opposite, Mouse.show(); will show the mouse:

X and Y
_x and _y variables can be used for a variety of purposes. These 2 variables represent the X and Y location of an object:

This example will have a variable named "answer", and it is equal to the X location of "button" subtracted by the Y location of "button". The answer will depend on where "button" is:

Alpha
Alpha can be changed in actionscript as well:

Instead of a number, a variable could be placed in the number's spot:

In the above example, the alpha of "button" will be 50.
Keyboard interaction
The keyboard can also be used for interaction with the flash program. In this example, the variable "number" will increase if you hold the UP key and decrease when the DOWN key is pressed.

The this.onEnterFrame means that anything between its 2 brackets ({ and }) will be active when the frame that it is on is active. Don't worry about it too much. The if and else if are to do with conditional statements, I will explain them later.
The if(Key.isDown(Key.UP)) literally means: If the key is down, the up key. There are other functions instead of isDown like isUp, addListener etc.
Playing and stopping

- Play makes the movie play.
- Stop makes the movie stop.
- Go to and play makes the movie go to the specified place and play.
- Go to and stop makes the movie go to the specified place and stop.
NOTE: If you are trying to stop movie clips or buttons from playing, you must specify the movie clip/button:

If you don't and just put a stop(); the timeline will stop, but movie clips /buttons that are already playing will keep playing. This way we have more control over what is going on.
NOTE: You can also specify what scene, frame label etc. to go to with the commands.
Conditional statements
Conditional statements are used when there is a variable that is going to be compared and the statement will be executed if the variable meets what is required. In this example, the output will say “Conditions has met the requirements” since the condition has been met.

In this example, the output will be “The number is 1 or greater”. Although the first condition hasn't been met the next one has. IF "number" was -1 then the output would be "The number is less than 0 or isn"t a number” because the first condition hasn't been met and neither has the second. Since there are no more conditions it then looks at the "else" and executes it. Think of it like this: If the number is 0, the output will be the first output otherwise if the number is greater or equal to 1 the output will be the second output, otherwise the output will be the last output.

In this example, nothing will happen since no conditions has been met and there is no "else":

NOTE: Numbers isn't the only thing that can be used in conditional statements.
Loops
Loops are like shortcuts and they are a quick way to do things. In this example, it will output the numbers from 1 to 99:

Think of it like this: Number is 0, number does not equal 100, add one to number and then it executes the functions within the loop and repeats until "number" is 100.
NOTE: For loops isn't the only type of loop.
Comments
Comments are used for marking things and making notes and explanations in the code:

The compiler will ignore all comments as they are for human reference only.
There are 2 types of comments:
/* */ - Everything between /* and */ will be a comment
// - Everything to the right of the // and on the same line is a comment
Another example:

Although it looks messy, it will still compile without errors since it is a comment. Think of comments as “invisible ink” to compilers:
