Actionscript Course

Before proceeding with the presentation of the ActionScript 3 language elements, here is a simple script to see from the beginning how easily you can create objects (text, shapes) into a Flash presentation using ActionScript code.
- Follow these steps:

  1. Open a new Flash document (ActionScript 3.0).
  2. Right-click on the first Frame in the Timeline, and then choose Actions.
  3. In the "Actions panel" (the window used to write ActionScript code) add the following code:
    var site:TextField = new TextField();     // declare the "site" variable ("TextField" type)
    site.text = "marplo.net";             // add a text in "site" variable
    addChild(site);            // add the variable (its value) in Flash presentation
    
  4. Press "Ctrl+Enter" to see the result
- This ActionScript code will display the text "marplo.net" in the Flash presentation.

You can create many other elements in a Flash presentation with ActionScript: lines, geometric shapes, animation, etc.
In the next example we add a square to the presentation created above (see also the explanations in comments).
  1. Continue the above example. In the same Actions panel add the code bellow, after the existing code, as shown in this immage:
    Simple script AS3
    - If you have closed the Actions panel, right-click on Frame 1 and choose "Actions".
    var square:Shape = new Shape;            // declare the "square" variable ("Shape" type)
    square.graphics.beginFill(0x08fe08);     // add a color to "square", with "beginFill(0xRRGGBB)
    
    // define the "square" (position and size, in pixels), with "graphics" property and "drawRect(X, Y, width, height)" method
    square.graphics.drawRect(0, 20, 100,100);
    addChild(square);                  // add the square in Flash presentation
    
  2. Press "Ctrl+Enter" to see the rezult. Flash will display a window with a text and a green square like in the picture below.
    Simple script AS3 2
The FLA file with this example can be downloaded from: Simple script AS3.

So, step by step, with ActionScript you can create complex Flash presentations, the objects you add and their properties can be controlled with AS3 methods and properties. For example, to add transparency to the square in the example above, you can use the "beginFill(color, nr_alpha)" method (for "nr_alpha" add a number between 0 and 1), like this: square.graphics.beginFill(0x08fe08, 0.5);

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which meta tag provides a short description of the page?
<meta content="..."> <meta description="..."> <meta http-equiv="...">
<meta name="description" content="70-160 characters that describes the content of the page" />
Which CSS property is used to stop the wrapping effect of the "float"?
clear text-align position
#some_id {
  clear: both;
}
Click on the method which gets an array with all the elements in the document that have a specified tag name.
getElementsByName() getElementById() getElementsByTagName()
var divs = document.getElementsByTagName("div");
var nr_divs = divs.length;
alert(nr_divs);
Indicate the PHP function which returns the number of elements in array.
is_[) count() strlen()
$arr =[7, 8, "abc", 10);
$nri = count($arr);
echo $nri;        // 4
A simple script ActionScript 3

Last accessed pages

  1. Get Lower, Higher, and Closest Number (5330)
  2. Creating Functions in ActionScript (1396)
  3. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (25997)
  4. SHA1 Encrypt data in JavaScript (35307)
  5. One Minute Wisdom (1775)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (207)
  2. Read Excel file data in PHP - PhpExcelReader (74)
  3. The Four Agreements (68)
  4. PHP Unzipper - Extract Zip, Rar Archives (66)
  5. Get and Modify content of an Iframe (52)
Chat
Chat or leave a message for the other users
Full screenInchide