ActionScript 3.0 is the internal programming language for Flash, Flex, and AIR (the Adobe Integrated Runtime application).
With AS3 (ActionScript 3.0) you can write instructions to control the elements in a Flash presentation. For example, you can add instructions for buttons to play and stop an animation, or to change the color and size of an object. Also, ActionScript can be used to add objects (shapes, lines, text) in a Flash presentation without creating them on the Stage.
ActionScript is the programming language used to create Flash games which can be included in Web pages.
ActionScript 3.0 was introduced by Adobe in 2006 with "Adobe Flex 2.0".
It is a scripting language similar to JavaScript, for example, both languages uses the keyword "var" to declare the variables, the strings are joined with the "+" character. If you know JvaScript, you'll understand and learn faster AS3.
ActionScript 3.0 requires an object-oriented approach, includes some of the new concepts of object-oriented programming (OOP): classes, objects, methods, and events.
To create a Flash presentation which uses ActionScript 3, open a new document choosing "ActionScript 3.0" from the "Create New" column in the Flash start window (or from File -> New).
You can place the ActionScript code in frames in the Flash Timeline, or you can place your code in a completely separate ActionScript (.as) file.
For a start it will be shown how to add the code directly into the document, in Frames in the Timeline.
After you have opened a new document, create a new Layer in the Timeline (from Insert -> Timeline -> Layer) and call it actions or scripts (you can change the name of the Layer by double-clicking on its name).
It's better to keep your ActionScript code in a single layer at the top of the timeline that holds only AS3 code. Also, you can use any name for this layer, but it's better to have a suggestive name.
The ActionScript code will be write in a special panel (an Actions panel, shown in the picture below).
To open the Actions panel, cick a keyframe where you want to add your code, then click
Window -> Acions (or press F9).
Actions panel
- The
Actions pannel is used to add code and AS3 instructions in the Flash document.
- At the bottom of the picture is the Timeline panel, with the layer "Actions" created for adding ActionScript codes to its Frames. The code here is added in the first keyframe.
- ActionScript type - choose the ActionScript version for the code write in Script pane
- Toolbox - holds a list of ActionScript objects, properties, methods, and events.
- Navigator pane - shows a list of Frames that have ActionScript code attached.
- Script tag - indicates which script is being edited.
- Pin Script - adds a tab for a selected script.
- Script pane - is where you type the ActionScript code.
- Help - provides online help.
- Script Assist - provides a visual interface for editing scripts (syntax completion and parameter descriptions).
- Options menu - contains options that control and format the Actions panel.
- Code Snippet - provides ActionScript 3.0 code segments to use in scripts.
- Toolbar Actions - provides helpful tools for working with your ActionScript code (the buttons are shown in the image below).
- Add script items - provides access to the same elements as the Actions toolbox.
- Find - searches your script for words and characters.
- Insert a target path - inserts a specific target clip into the action.
- Click this button, and then choose your target object from a list, and this tool writes the proper code identifying it.
- Check syntax - checks the current action for syntax errors.
- Autoformat - formats your script, making it easier to read, by using colors and indents.
- To set formatting options, go to Edit -> Preferences -> ActionScript.
- Show code hint - gives you hints to the syntax of the action as you type.
- Debug options - add or remove breakpoints into the action to pause on the specified line of code, giving you an opportunity to examine your program.
- Expand all - expands collapsed portions of your script after you've used "Collapse selection" or "Collapse between braces".
- Collapse selection - collapses selection.
- Select the text you want to hide, and then click this button to hide it.
If you hold down the Alt key when you click this button, the Actions panel collapses the code not selected.
- Collapse between braces - hides the text between a set of curly braces {}.
- Apply block comment - inserts the /* and */ used to create a block comment.
- Apply inline comment - inserts the // used to create an inline comment.
- Remove comment - removes the comment characters from a comment.
- Show/Hide toolbox - creates more room for the Script pane, hiding the Actions toolbox.
- When the toolbox is hidden, you can use the "Add script items" button to insert elements.
AS3 is case-sensitive, so: "you", "You" and "YOU" are three different things.
Daily Test with Code Example
HTML
CSS
JavaScript
PHP-MySQL
Which tag is used to add lists into <ul> and <ol> elements?
<dt> <dd> <li><ul>
<li>http://coursesweb.net/html/</li>
<li>http://coursesweb.net/css/</li>
</ul>
Which value of the "display" property creates a block box for the content and ads a bullet marker?
block list-item inline-block.some_class {
display: list-item;
}
Which instruction converts a JavaScript object into a JSON string.
JSON.parse() JSON.stringify eval()var obj = {
"courses": ["php", "javascript", "ajax"]
};
var jsonstr = JSON.stringify(obj);
alert(jsonstr); // {"courses":["php","javascript","ajax"]}
Indicate the PHP class used to work with HTML and XML content in PHP.
stdClass PDO DOMDocument$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue; // CoursesWeb.net