|


The course is based around the creation of the kind of Flash interface that intermediate to advanced developers are often required to produce in industry.
While it may appear simple, it is designed to teach principles and is:
- Entirely dynamic (fed from XML and external content)
- Entirely generated with ActionScript 3.0
The project consists of an interface that fills the entire browser area with the Flash stage, but the content remains centred. It uses a total of six discrete classes and features dynamic text, masking, event handling and preloading of external content.
The trainee is taken through everything from choice of software tools to the planning of the project to the writing of the code and the completion of the project, covering numerous features of ActionScript 3.0 along the way.
Because the course is "workshop" based, working towards a realistic goal, topics are covered in context - as a means to an end - rather than in theoretical isolation. One of the things we would frequently hear when training courses written by others is:
"I understand it, but I'm not sure how I would use it"
We're confident that in this course it is always clear why things are being done and how techniques can be re-applied in the future.

Here are some samples of the course content so that you can get an idea of its tone and level:
Import statements
Import statements are used to specify a shortcut to the location of another class that might be utilised by this one. For example, if we wanted to use the class Sprite, which is a display object, inside AccordionMenuItem (which we will do later), we could either refer to it like this when we needed it:
var newSprite:flash.display.Sprite = new flash.display.Sprite();
Or, we could define an import statement, just once at the top of our code, then refer to Sprite more easily whenever we need it:
/**************** IMPORTS ****************/
import flash.display.Sprite;
import flash.display.Shape;
[Later:]
var newSprite:Sprite = new Sprite();
Notice that there are actually two import statements above. These are making available to us two different classes. Since they are both in the same package, we could import them both in one go using a wildcard:
import flash.display.*;
Constructor functions
Constructor functions are a special type of function, not really a static method or an instance method. They are only defined in non-static classes (those which enable instances). They are triggered automatically when a new instance of a class is requested (for example when a new array is created, the Array constructor function is triggered).
A few notes on constructor functions:
- They should be declared with the “public” prefix
- They may accept parameters
- They must not have a return value
- They must be named exactly the same as the class name
Instance methods
After the constructor function for a class come the instance methods. Like verbs in English, these are any things that the class instance should be able to “do” as opposed to “have”. Just as a dog “has” an eye colour, it can also bark, and as a MovieClip has a height, it can also startDrag() to begin following the mouse.
Creating the shell of the AccordionMenu class
- Make a copy of the CourseTemplate.as file in the assets folder
- Drag this copy into the global classpath com.orlandmedia.accordionmenu
- Rename the file AccordionMenu.as
- Open the file
- Fill in its name
- The package path must be relative to where the file is located. Accordingly enter:
package com.orlandmedia.accordion {
- Our accordion menu object type will be another Sprite with additional capabilities. So enter:
public class AccordionMenu extends Sprite {
- Define the following instance variable:
/******** Instance variables ********/
private var _owner:DisplayObject; // object owning this
- Go down to the constructor function and amend it to accept (for now) one parameter: the object to which the menu belongs (which must be a DisplayObject):
public function AccordionMenu(owner:DisplayObject)
- Inside the constructor function, the first thing we will do is take a permanent note of the owner. We’ll take the incoming value and assign it to the instance property we created:
public function AccordionMenu(owner:DisplayObject, dataSource:XML) { trace("instantiating " + this); _owner = DisplayObject(owner); }
- Ensure your imports block looks like this:
/************** IMPORTS **************/
import flash.display.*;
|