Article location:
http://senocular.com/flash/tutorials/as3withmxmlc/
The package declaration is new to ActionScript 3.0. It replaces the fully-qualified names for classes used in ActionScript 2.0. It follows that:
class mx.controls.Button { ... }
becomes
package mx.controls { class Button { .. } }
- “…a Sprite is basically a movie clip without a timeline and frames…”
Extending Sprite is the basic technique for displaying an object in Flash using ActionScript 3. This is the form:
package { import flash.display.Sprite;
public class BareBones extends Sprite
{
}
}
- “Objects you can see in the Flash player are known as display objects and are derived from the DisplayObject class. Such classes include, but are not limited to: Sprite, MovieClip (which is a subclass of Sprite), TextField, Bitmap, and Shape. All DisplayObject classes inherit from EventDispatcher so are inherently event-capable. In addition, the Sprite, MovieClip, and TextField classes (along with some others) inherit from the InteractiveObject class meaning they can recieve events from the mouse and keyboard such as mouseOver, click, and keyUp. Sprite and MovieClip also inherit from a class called DisplayObjectContainer meaning that they can contain other display objects within them. The application class of a SWF is derived from the Sprite class so it too is a DisplayObjectContainer. As such, it can add other classes to it as children.”
For the reader who may care just a little about Flex MXML (or using ActionScript 3 to render display objects behind MXML), the importance of the UIComponent Class cannot be overestimated and should be included in the list classes quoted above… In fact, when programmatically generating objects for display in Flex containers, the UIComponent should be used instead the Sprite. The location of UIComponent in the Adobe® Flex™ 2.0.1 Language Reference:
http://livedocs.adobe.com/flex/201/langref/mx/core/UIComponent.html
-
“The management of display objects in ActionScript 3 has completely changed. No longer do you use attachMovie, createEmptyMovieClip, or createTextField etc to create new MovieClip or TextField instances. Instead, you use the new keyword to create new instances of these objects and then add them to a DisplayObjectContainer using the addChild (or similar) method. If not added to a DisplayObjectContainer, the objects will exist and can be manipulated but are never seen as they will exist only in code.”
-
“With ActionScript 3 also came some changes to the vector drawing API. Not only are there a couple of new methods such as drawCircle and drawRect, but the API is also no longer associated directly with MovieClip instances. Instead, the drawing API is now used on Graphics class instances.”
It is important to stress that all vector drawing tasks are confined in the new Graphics class. The location of Graphics in the Adobe® Flex™ 2.0.1 Language Reference:
http://livedocs.adobe.com/flex/201/langref/
flash/display/Graphics.html
The Adobe documentation states, “You cannot create a Graphics object directly from ActionScript code. If you call new Graphics(), an exception is thrown.” Instead, you obtain an instance of the Graphics class from Shape, Sprite, and MovieClip (or their respective subclasses like UIComponent of FlexSprite).
- “…mxmlc.exe will recognize meta tags within the ActionScript that allow you to embed assets into the published swf and have those assets accessible as a custom class. The meta tag allowing you to do this is Embed meta tag.”
Unfortunately, this embed annotation does not declare support vector formats.
- “There are no more ‘on’ event methods and no more addListener for objects like Mouse and Stage. Every event handler created will be associated with an event through addEventListener(); Note: There is no longer a need for the Delegate class used in ActionScript 2 since listener functions maintain their original scope.”
For more details, read “Tips for learning ActionScript 3.0” by Emmy Huang of Adobe here:
http://www.adobe.com/devnet/actionscript/
articles/actionscript_tips.html