Flash ActionScript 3 overview: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
m (Text replacement - "<pageby nominor="false" comments="false"/>" to "<!-- <pageby nominor="false" comments="false"/> -->")
 
(40 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Under construction}}
{{Incomplete}}
<pageby nominor="false" comments="false"/>
<!-- <pageby nominor="false" comments="false"/> -->


Disclaimer: Until today I have never ''seen'' any ActionScript code. I will use this page to write down a few things. Wait until this message goes away before you can trust anything ! - [[User:Daniel K. Schneider|Daniel K. Schneider]] 15:56, 5 September 2007 (MEST). Some links (there are mostly ''just'' links in here) may be useful though.
== ActionScript 3 overview information ==


This is part of the [[Flash]] series of articles. But it is '''not''' a tutorial !!
This is part of the [[Flash]] and [[ActionScript]] series of articles. But it is '''not''' a tutorial. The purpose of this entry is to provide some general information about ActionScript and some useful links.
 
See also:
* The entry page for AS3 tutorials in this wiki is [[Actionscript 3]].
* [[Flash and AS3 links - general]]
* [[Flash and AS3 links - tutorials]]
* [[Flash and AS3 links - documentation]] (Flash and AS3 Books, Reference Manuals and Cheatsheets)
* [[Flash and AS3 links - toolkits]] (AS 3 Toolkits, Libraries, Flash reusable components, AS 3 reusable code, etc.)


== Introduction - Writing and using AS Code ==
== Introduction - Writing and using AS Code ==


{{quotation|ActionScript 3.0 is a dialect of [[ECMAScript]] which formalizes the features of ActionScript 2.0, adds the capabilities of ECMAScript for XML (E4X), and unifies the language into a coherent whole.}} (Grossman, 2006).
{{quotation|ActionScript 3.0 is a dialect of [[ECMAScript]] which formalizes the features of ActionScript 2.0, adds the capabilities of [[ECMAScript for XML]] (E4X), and unifies the language into a coherent whole.}} (Grossman, 2006). ActionScript 3 was built on a proposal for ECMAScript 4.0 that then got rejected or stalled. Read Mike Chambers' piece on [http://www.mikechambers.com/blog/2008/08/14/actionscript-3-and-ecmascript-4/ ActionScript 3 and ECMAScript 4].


Basically, there are different ways of using ActionScript 3:
Basically, there are two different ways of using ActionScript 3. Each has sub variants:


1. Within a Flash CS3 environment:
1. Within a Flash CS3 environment:
* Use the '''Flash CS3 environment''' more less as "in the ActionScript 2" way, i.e. you add bits of code to certain frames
* Use the '''Flash CS3 environment''' more or less as "in the ActionScript 2" way, i.e. you add bits of code to certain frames and that refer to objects in the library and/or on the stage.
* Write action code with a class structure in a file, then import to a frame through the properties panel.
* Write action code with a class structure in a file, then import to a frame through the properties panel.
* Write your code in a file and compile it (you also may use Flash CS3 that way). No drawings, just code !  
* Write your code in a file and compile it (you also may use Flash CS3 that way). No drawings, just code !  


2. Within a [[Adobe Flex]] environment:
2. Within an [[Adobe Flex]] environment:
Flex is a framework introduced by Adobe that also compiles into swf files. Flex is meant to make it easier to conceive rich Internet applications that contain a variety of interactive interface elements (buttons, textfields, lists of images, etc.). The [http://www.adobe.com/products/flex/sdk/ Flex SDK] is free to use but lives in a command line environment. [http://www.adobe.com/products/flex/flexbuilder/ Flex Builder] provides a visual development environment. It is due to become free for students and educators starting early November.  
Flex is a framework introduced by Adobe that also compiles into swf files. Flex is meant to make it easier to conceive rich Internet applications that contain a variety of interactive interface elements (buttons, textfields, lists of images, etc.). The [http://www.adobe.com/products/flex/sdk/ Flex SDK] is free to use but lives in a command line environment. [http://www.adobe.com/products/flex/flexbuilder/ Flex Builder] provides a visual development environment. It is free for students and educators starting (upon request).
* Use the actionscript compiler bundled in the Flex framework to compile AS3 files. This is explained in details in [http://www.senocular.com/flash/tutorials/as3withmxmlc/ Sernocular's Beginner Guide to Getting Started with AS3 (Without Learning Flex)]. It explains how to use any editor plus the '''mxmlc''' compiler.
* Use the actionscript compiler bundled in the Flex framework to compile AS3 files. See also our own [[Adobe Flex]] installation tips and [[AS3 Compiling a program]]
* Write a Minimal MXML application that contains little else than a call to a main function. An example of this can be found in  [http://www.moock.org/eas3/examples Minimal MXML example by Moock].  
* Write a Minimal MXML application that contains little else than a call to a main function. An example of this can be found in  [http://www.moock.org/eas3/examples Minimal MXML example by Moock].  
* Write a Flex/MXML document that includes a script element. The use of actionscript within a &lt;mx:Script&gt; tag is explained in the [http://livedocs.adobe.com/flex/201/langref/mxml/script.html Flex Language Reference] or this blog post on [http://kanuwadhwa.wordpress.com/2007/10/05/using-actionscript-in-flex-applications/ Using ActionScript in Flex applications]
* Write a Flex/MXML document that includes a script element. The use of actionscript within a &lt;mx:Script&gt; tag is explained in the [http://livedocs.adobe.com/flex/201/langref/mxml/script.html Flex Language Reference] or this blog post on [http://kanuwadhwa.wordpress.com/2007/10/05/using-actionscript-in-flex-applications/ Using ActionScript in Flex applications]
Line 45: Line 52:
# Save your changes to the FLA file.
# Save your changes to the FLA file.


Note for Flash designers: Some of the code in the Flash doc can be fairly easily simplified to work with the simple timeline scripting method. Other can not and you do have to code with a "class structure".
Note for Flash designers: Some of the code in the Flash doc can be simplified to work with the "timeline scripting method". Other code can not and you do have to code with a "class structure".


=== Stand-alone code development with AS 3 ===
=== Stand-alone AS3 code development / SDK and editors ===


You do not need to buy Flash CS3 (that's actually a cool thing) to program in AS3 and to create *.swf files. You can either use:
You do not need to buy Flash CS3 (that's actually a cool thing) to program in AS3 and to create *.swf files. You can either use:
* Flex Builder - an Eclipse plugin
* Flex Builder - a commercial Eclipse plugin available from [http://www.adobe.com/products/flex/downloads/ Adobe] (free for education upon request).
* Just the Flex SDK
* Just the [http://www.adobe.com/products/flex/downloads/ Flex SDK] together with a "normal" programming editor.
 
; The Flex SDK 2.0.1 (or better) from Adobe
* Download this free SDK from Adobe:
:http://www.adobe.com/products/flex/downloads/
 
For Windows and Mac there is a Flex Builder plugin for Eclipse.
Otherwise there is a platform independent compiler, the Adobe Flex2 Software Development Kit (SDK).


; Installing the Adobe Flex2 Software Development Kit (SDK) for Windows
In addition you may use [[MXML]], an [[XML]]-based user interface markup language.
* Unzip it somewhere
* Edit the Environment variables through the configuration panel to include the bin directory in the path: I.e. something like ''Parameters->Config Panel->System->Advanced'' (I don't have an English System at hand).


; Installing the Adobe Flex2 Software Development Kit (SDK) for Ubuntu
Read [[Adobe_Flex#Installing_the_Flex_Framework|how to install the Flex Framework]].
* Unzip it somewhere (I put it under /usr/local/flex)
* Under Linux change permissions of the shell scripts in the bin directory, in particular ''mxmlc''
* Then add this directory to your path. E.g. under my Ubuntu I added in file ''/etc/bash.bashrc'':
export PATH=${PATH}:/usr/local/flex/bin
 
; Installing the Adobe Flex2 Software Development Kit (SDK) for Mac OSX
* Unzip it somewhere (I put it under /Applications/flex_sdk/flex_sdk2/)
* Open terminal, go to the flex_sdk directory. Make sure the files in the bin directory have the right permissions. Type "ls-al". File details should start with "-rwx". If no "x" appears, type "chmod u+x *" to give execution permission to all files in that directory.
* Then add this directory to your system paths. Go to your home directory ("cd $home"), edit the file (in the terminal window, type "open .profile" or "mate .profile" if you have textmate installed). Add the path to the file.
export PATH=$PATH:/Applications/flex_sdk/flex_sdk_2/bin/
Save the file. Then make sure the profile file is being initiated.
source .profile
If you have the TextMate code editing software installed, download the [http://www.flashalisious.com/2007/07/30/installing-as3-and-flex-bundle-for-textmate/ Flex and AS3 Bundles for TextMate].


; Using the compiler
; Using the compiler
* Just type something like:
* Just type something like:
mxmlc HelloWorld.as  
  mxmlc HelloWorld.as  
.... This will make an *.swf file
.... This will make an *.swf file


; Development support other than Eclipse
; Development support other than Eclipse
I find these IDEs too hard to use (I only occasionally program and just use the Emacs editor and don't want learn full Flex yet). So I need some Emacs code for help with editing (not done yet)
If you find IDEs (.e. the Flash builder) too hard to use you can find editors with ActionScript support or at least syntax support for JavaScript/Java, e.g.
* e.g. http://nisheet.wordpress.com/tag/emacs/
* [http://www.flashdevelop.org/ Flashdevelop]
* [[Emacs]] (read this if you know about Emacs)
* [http://www.jedit.org/ JEdit]. You can use the Java beautifier, but you may have to find the plugins with google and install manually. Btw. JEdit also has a wikipedia mode)
* If configuring and learning Flashdevelop, Emacs, JEDIT etc appears too complex to master, a very easy to use editor in Unix/Linux environments is [http://www.computerhope.com/unix/upico.htm pico] (but you will not get any syntax support). See [[text editor]] article in this wiki for a discussion/presentation of some editing software.
* Finally, you also can use the CS3/Flash ActionScript editor if you own this package.


== The class hierarchy ==
== The class hierarchy ==
Line 105: Line 94:
The ActionScript 3.0 flash.display package defines a whole lot of different kinds of visual objects that can appear in the Flash Player. '''DisplayObject''' is a child of EventDispatcher, child of Object
The ActionScript 3.0 flash.display package defines a whole lot of different kinds of visual objects that can appear in the Flash Player. '''DisplayObject''' is a child of EventDispatcher, child of Object


Below is summary table of ActionScript 3 interactive display objects. It shows that interactive objects are defined as hierarchical classes. Methods and properties that work for a parent class (e.g. Sprite) also will work for its child classes (e.g. UIComponent). Links point to the technical reference manual at Adobe.
Below is summary table of '''AS3 / Flash 9 / CS3''' interactive display objects (not covering Flex). It shows that interactive objects are defined as hierarchical classes. Methods and properties that work for a parent class (e.g. Sprite) also will work for its child classes (e.g. UIComponent). Links point to the technical reference manual at Adobe. Please note that the graphics are defined by very different classes. Graphics are inserted into the ''graphics'' properties of display objects.


* [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html DisplayObject], see also [http://livedocs.adobe.com/flash/9.0/main/00000143.html Core display classes] overview.
* [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html DisplayObject], see also [http://livedocs.adobe.com/flash/9.0/main/00000143.html Core display classes] overview.
Line 112: Line 101:
*### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html Loader]: Class for loading objects (Bitmaps, AS3 Sprites or Movieclips, or AS 1/2 AVM1Movie).
*### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html Loader]: Class for loading objects (Bitmaps, AS3 Sprites or Movieclips, or AS 1/2 AVM1Movie).
*### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Sprite.html Sprite]: Manipulable container of objects
*### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Sprite.html Sprite]: Manipulable container of objects
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html FLVPlayback] FLVPlayback]
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlaybackCaptioning.html FLVPlaybackCaptioning]
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/MovieClip.html MovieClip]: refers to a movie clip symbol created in the Flash authoring tool.
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/MovieClip.html MovieClip]: refers to a movie clip symbol created in the Flash authoring tool.
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/core/UIComponent.html UIComponent]
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html FLVPlayback] FLVPlayback] (CS3 only)
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlaybackCaptioning.html FLVPlaybackCaptioning] (CS3 only)
*#### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/core/UIComponent.html UIComponent] (only in CS3, Flex has equivalent [[MXML]] classes)
*##### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/BaseButton.html BaseButton]
*##### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/BaseButton.html BaseButton]
*##### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/containers/BaseScrollPane.html BaseScrollPane]
*##### [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/containers/BaseScrollPane.html BaseScrollPane]
Line 138: Line 127:
*# StaticText: Frozen text
*# StaticText: Frozen text
*# Video: contains video
*# Video: contains video
Below is a '''Flash 10/ CS5''' version
* [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/index.html DisplayObject]
*# [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/InteractiveObject.html InteractiveObject] (base class for all interactive objects)
*## [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html DisplayObjectContainer]
*### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html Loader]
*### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Sprite.html Sprite] Sprites are like Movie Clips without timeline
*#### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/video/FLVPlayback.html FLVPlayback]
*#### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/video/FLVPlaybackCaptioning.html FLVPlaybackCaptioning]
*#### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/html/HTMLLoader.html HTMLLoader]
*#### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MovieClip.html MovieClip]
*#### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/core/UIComponent.html UIComponent] Includes several subclasses, for example:
*##### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/BaseButton.html BaseButton]
*##### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/TextArea.html TextArea]
*### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html Stage]
*### [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/engine/TextLine.html TextLine]
*## [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/SimpleButton.html SimpleButton]
*## [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html TextField]
*# [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/AVM1Movie.html AVM1Movie]
*# [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Bitmap.html Bitmap]
*# [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MorphShape.html MorphShape]
*# [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Shape.html Shape] is a very light-weight display object (as opposed to a Sprite)
*# [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StaticText.html StaticText]
*# [http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Video.html Video]


=== Events ===
=== Events ===


The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event listeners when an event occurs. Event is a direct child of the object. There are 26 direct subclasses and Flex has even more. We only will show a few here.
The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event listeners when an event occurs. Event is a direct child of the object. There are 26 direct subclasses for Flash (CS3) and Flex (MXML) has even more. We only will show a few flash and fl events.


* [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html Event]
* [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html Event]
Line 164: Line 178:
* '''Display object containers''', i.e. objects that can contain both simple display objects and other display object containers.
* '''Display object containers''', i.e. objects that can contain both simple display objects and other display object containers.
* (Simple) ''' display objects'''
* (Simple) ''' display objects'''
Read for example [http://developer.yahoo.com/flash/articles/display-list.html Introduction to the Display List] (Yahoo developper network) or [http://www.flashandmath.com/intermediate/names/index.html Creating, Deleting and Accessing Display Objects at Runtime in Flash CS3] if you want to learn how to code adding
and removing display objects.


=== Stage and Timeline ===
=== Stage and Timeline ===
Line 170: Line 187:
{{quotation|To summarize: one stage, one root per SWF (which is the main timeline) and that root is an instance of a document class or the MainTimeline class if a document class isn't provided}}
{{quotation|To summarize: one stage, one root per SWF (which is the main timeline) and that root is an instance of a document class or the MainTimeline class if a document class isn't provided}}


== AS 3 coding notes ==
== Action Script entries in this wiki ==
 
(I will kill this section later ... i.e. once I got some tutorials with code inside)
 
=== Event handling ===
 
; General pattern
   
Definition of an event handler function:
function ''eventResponse'' (eventObject:EventType):void
  {
    // Actions performed in response to the event go here.
  }
 
Using it:
eventSource.addEventListener(EventType.EVENT_NAME, ''eventResponse'');
 
; Example
 
launch_button.addEventListener(MouseEvent.CLICK,launchRocket);
function launchRocket(event:MouseEvent):void {
    gotoAndPlay(2);
}
 
See [[ActionScript 3 event handling tutorial]]. You also can see an example in the [[Flash button tutorial]]
 
== Documentation Links ==
 
See also [[Adobe Flex]]


=== Reference manuals ===
=== Action Script tutorials ===


* [http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/ ActionScript 3.0 Language & Component Reference]
(1) In this wiki we teach some Action Script to Flash designers, e.g.:
* [http://livedocs.adobe.com/flex/201/langref/ Adobe Flex 2.0.1 Language Reference]
* [[Flash button tutorial]]
* [http://www.adobe.com/go/programmingAS3 Flex 2 LiveDocs: Programming ActionScript 3.0]
* [[ActionScript 3 event handling tutorial]].
* [[ActionScript 3 interactive objects tutorial]]
* [[Flash embedded movie clip tutorial]]
See the [[Flash tutorials]] entry for a full list.


=== Other documentation ===
(2) Then we also have "pure" Action Script tutorials for people who wish to learn how to program.
* The entry point is [[Actionscript 3]] As of november 2007 there is a complete list of '''novice''' tutorials. Other levels are under constuction. Start with:
** [[Adobe Flex]] (includes how to install the Flex SDK)
** [[AS3 Compiling a program]]
** [[AS3 Tutorials Novice]]


* [http://livedocs.adobe.com/flash/9.0/main/ Adobe Livedocs] has fairly good documentation (maybe not suitable for beinners) e.g.
* All the Actionscript related articles are tagged with [[:Category:Actionscript 3|Actionscript 3]]. Alternatively, see [[:Category:Tutorials|Tutorials]]
** [http://livedocs.adobe.com/flash/9.0/main/00000012.html Getting started with ActionScript]


* [http://labs.adobe.com/wiki/index.php/ActionScript_3 ActionScript 3] from Adobelabs. Maybe superseded by the above doc, maybe not ...
=== Useful Links pages in this wiki ===


* [http://actionscriptcheatsheet.com/ ActionScriptCheatSheet.com] Look at the [http://actionscriptcheatsheet.com/blog/quick-referencecheatsheet-for-actionscript-20/ downloads]. Several excellent ActionScript cheatsheets.
* [[Flash and AS3 links - general]] Links to Flash/AS3 websites, propaganda and such...
* [[Flash and AS3 links - tutorials]] Links to (hopefully) good tutorials on other web sites.
* [[Flash and AS3 links - documentation]] (Flash and AS3 Books, Reference Manuals and Cheatsheets)
* [[Flash and AS3 links - toolkits]] (AS 3 Toolkits, Libraries, Flash reusable components, AS 3 reusable code, etc.)


=== AS2 vs. AS3 comparisons ===
== Links ==


* [http://www.adobe.com/devnet/actionscript/articles/display_api.html Understanding the changes in the display API in ActionScript 3.0] (short example code comparison)
Most links are in specialized links pages (see just above)
 
* [http://livedocs.adobe.com/flex/201/langref/migration.html ActionScript 2.0 Migration] (Adobe). This list list is huge :)
 
=== Overviews ===
 
* Grossman, Gary and Huang, Emmy (2006). [http://www.adobe.com/devnet/actionscript/articles/actionscript3_overview.html ActionScript 3.0 overview], Adobe.
* [http://en.wikipedia.org/wiki/Actionscript ActionScript] (Wikipedia)
* [http://flexblog.faratasystems.com/?p=115 Comparing the syntax of Java 5 and ActionScript 3]
 
== Tutorials ==
 
=== General AS 3 Tutorials ===
 
* Adobe's [http://www.adobe.com/devnet/flash/ Developer Center] includes many "quickstart" articles but also more substantial tutorials and finally book excerpts. Examples:
 
** [http://www.adobe.com/devnet/flash/articles/filtering_data_e4x_print.html  Filtering XML data in Flash applications using ECMAScript for XML]
** [http://www.adobe.com/devnet/flash/quickstart/datagrid_pt3/ Filtering and formatting data in the DataGrid component]
** [http://www.adobe.com/devnet/flash/actionscript.html ActionScript and object-oriented programming] (several good tutorials at Adobe's Flash Developer Center)
** [http://www.adobe.com/devnet/actionscript/articles/as3_cookbook_excerpts.html ActionScript 3.0 Cookbook excerpts: From custom classes to the rendering model] (Several free chapters of this book)
** [http://www.adobe.com/devnet/actionscript/#migrating_as3 Migrating your Flash applications to ActionScript 3.0]
 
* [http://www.senocular.com/flash/tutorials/as3withflashcs3/ Getting Started with ActionScript 3.0 in Adobe Flash CS3]
 
* [http://www.actionscript.org/resources/categories/Tutorials/ Tutorials] at ActionScript.org has several action script tutorials, e.g.
** [http://www.actionscript.org/resources/articles/611/1/Getting-started-with-Actionscript-3/Page1.html Getting started with Actionscript 3]
 
* [http://www.kirupa.com/developer/flash/index.htm Kirupa], e.g.
** [http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm Using XML in Flash CS3/AS3]
 
 
 
* [http://www.flepstudio.org/english/blogsection/tutorials.html Flepstudio] has a series of tutorials.
 
* [http://www.flash-db.com/Tutorials/ Flash-db.com] has a series of tutorials.
 
=== Component programming ===
 
(to sort out)
* [http://drawk.wordpress.com/2007/06/03/as3-mouse-events-and-mouse-related-user-actions/ AS3 Mouse Events and Mouse Related User Actions] by Drawk - Really useful.
 
* [http://blog.benstucki.net/?id=19 Quick Tips for Making ActionScript 3 Components] by Ben Stucki.
 
* [http://www.kirupa.com/forum/forumdisplay.php?f=141  ActionScript 3.0 Forums] at Kirupa.com. Also includes [ ActionScript 3 Tip of the Day]
 
* [http://www.kirupa.com/developer/flashcs3/animating_dynamic_movieclips_AS3_pg1.htm Animating Dynamic MovieClips in AS3] by Kirupa.
 
* [http://www.kirupa.com/forum/showthread.php?t=101228  Sending Variables to PHP from Flash And Back again!] (AS2)
 
* [http://blog.3r1c.net/ Eric Cancil]. A blog with AS3 code.
 
* [http://www.uza.lt/ $.console] A console for debuggin, pops up over your application (looks good, not tested so far).
 
=== AS 3 Example-based tutorials ===
 
* [http://www.webwasp.co.uk/tutorials/102/index.php Flash Tutorial - Copy Motion as ActionScript 3.0]
* [http://as3.metah.ch/ Metah.ch] has a series of tutorials with source code.
 
=== AS 3 Examples ===
 
* [http://www.zeuslabs.us/flex-2-treemap-component/ Flex Treemap Component]
* [http://drawk.wordpress.com/2007/06/25/updated-list-of-best-animation-packages-for-as3/ Updated: List of Best Animation Packages for AS3]
* [http://labs.zeh.com.br/blog/?p=100 On user-triggered and user-controlled interface animation]
 
== Reusable components and libraries ==
 
* [http://code.google.com/p/tweener/ Tweener] Tweener (caurina.transitions.Tweener) is a Class used to create tweenings and other transitions via ActionScript code for projects built on the Flash platform.
 
* [http://blog.greensock.com/tweenliteas3 TweenLite]. TweenLite (AS3) - A Lightweight (2K) Yet Powerful Tweening Engine.
 
* [http://blog.greensock.com/tweenfilterliteas3/ TweenFilterLite]. TweenFilterLite extends the extremely lightweight (2k), powerful TweenLite "core" class, adding the ability to tween filters (like blurs, glows, drop shadows, bevels, etc.) as well as image effects like contrast, colorization, brightness, saturation, hue, and threshold (combined size: 5k).
 
* [http://www.themidnightcoders.com/weborb/php/ WebORB for PHP] (should be move to Flex). erver-side technology enabling connectivity between Flex and Flash Remoting clients and PHP applications.
 
== Other ==


=== Development environments ===
=== Development environments ===
Line 304: Line 227:
* [http://www.websector.de/blog/ WS-Blog] by Jens Krause.
* [http://www.websector.de/blog/ WS-Blog] by Jens Krause.


[[Category: Multimedia]]
 
[[Category: Technologies]]
 
[[Category: Authoring tools]]
 
 
[[Category: Flash]]
[[Category: Flash]]
[[Category: Rich internet applications]]
[[Category: Rich internet applications]]
[[Category: Actionscript 3]]

Latest revision as of 18:16, 22 August 2016

ActionScript 3 overview information

This is part of the Flash and ActionScript series of articles. But it is not a tutorial. The purpose of this entry is to provide some general information about ActionScript and some useful links.

See also:

Introduction - Writing and using AS Code

“ActionScript 3.0 is a dialect of ECMAScript which formalizes the features of ActionScript 2.0, adds the capabilities of ECMAScript for XML (E4X), and unifies the language into a coherent whole.” (Grossman, 2006). ActionScript 3 was built on a proposal for ECMAScript 4.0 that then got rejected or stalled. Read Mike Chambers' piece on ActionScript 3 and ECMAScript 4.

Basically, there are two different ways of using ActionScript 3. Each has sub variants:

1. Within a Flash CS3 environment:

  • Use the Flash CS3 environment more or less as "in the ActionScript 2" way, i.e. you add bits of code to certain frames and that refer to objects in the library and/or on the stage.
  • Write action code with a class structure in a file, then import to a frame through the properties panel.
  • Write your code in a file and compile it (you also may use Flash CS3 that way). No drawings, just code !

2. Within an Adobe Flex environment: Flex is a framework introduced by Adobe that also compiles into swf files. Flex is meant to make it easier to conceive rich Internet applications that contain a variety of interactive interface elements (buttons, textfields, lists of images, etc.). The Flex SDK is free to use but lives in a command line environment. Flex Builder provides a visual development environment. It is free for students and educators starting (upon request).

Using ActionScript like a Flash Designer

  • Create a new layer
  • Click on a frame (typically frame 1)
  • Hit F9, the copy/paste or write your code

This is the way most of the Flash examples made in our tutorials were made

Scripting in the timeline does not require from you to use classes. However, sometimes you need to import packages, i.e. when Flash whines that it can't find a method. Examples are:

import Fl.managers.FocusManager; // to work with keypress events
import fl.video.MetadataEvent;  // to work with cue points in flv videos

Using ActionScript classes in CS3

Most examples in the official Using ActionScript 3.0 Components and ActionScript 3.0 Language and Components Reference are made with a class structure and require that you learn this (read also Using examples in the ActionScript 3.0 Language Reference):

  1. Write code in a AS file and give the file the same name as the primary class (for example: ContextMenuExample.as).
  2. Create and save a new empty FLA file in the same directory as the AS file.
  3. In the Properties tab of the Property inspector enter the class name of the primary class for the example in the Document class text box (for example: ContextMenuExample).
  4. Save your changes to the FLA file.

Note for Flash designers: Some of the code in the Flash doc can be simplified to work with the "timeline scripting method". Other code can not and you do have to code with a "class structure".

Stand-alone AS3 code development / SDK and editors

You do not need to buy Flash CS3 (that's actually a cool thing) to program in AS3 and to create *.swf files. You can either use:

  • Flex Builder - a commercial Eclipse plugin available from Adobe (free for education upon request).
  • Just the Flex SDK together with a "normal" programming editor.

In addition you may use MXML, an XML-based user interface markup language.

Read how to install the Flex Framework.

Using the compiler
  • Just type something like:
 mxmlc HelloWorld.as 

.... This will make an *.swf file

Development support other than Eclipse

If you find IDEs (.e. the Flash builder) too hard to use you can find editors with ActionScript support or at least syntax support for JavaScript/Java, e.g.

  • Flashdevelop
  • Emacs (read this if you know about Emacs)
  • JEdit. You can use the Java beautifier, but you may have to find the plugins with google and install manually. Btw. JEdit also has a wikipedia mode)
  • If configuring and learning Flashdevelop, Emacs, JEDIT etc appears too complex to master, a very easy to use editor in Unix/Linux environments is pico (but you will not get any syntax support). See text editor article in this wiki for a discussion/presentation of some editing software.
  • Finally, you also can use the CS3/Flash ActionScript editor if you own this package.

The class hierarchy

At the origin, there is the Object. It has many subclasses (about 151 I'd say).

EventDispatcher

EventDispatcher implements is the base class for the DisplayObject class, i.e. all displayed objects. It is a direct child of Object and has 29 subclasses. A few are:

The DisplayObject

The ActionScript 3.0 flash.display package defines a whole lot of different kinds of visual objects that can appear in the Flash Player. DisplayObject is a child of EventDispatcher, child of Object

Below is summary table of AS3 / Flash 9 / CS3 interactive display objects (not covering Flex). It shows that interactive objects are defined as hierarchical classes. Methods and properties that work for a parent class (e.g. Sprite) also will work for its child classes (e.g. UIComponent). Links point to the technical reference manual at Adobe. Please note that the graphics are defined by very different classes. Graphics are inserted into the graphics properties of display objects.

Below is a Flash 10/ CS5 version

Events

The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event listeners when an event occurs. Event is a direct child of the object. There are 26 direct subclasses for Flash (CS3) and Flex (MXML) has even more. We only will show a few flash and fl events.

Interfaces:

When Flash executes

The display list

At at given time in your animation, your Flash application contains a hierarchy of displayed objects: the display list. It contains all the visible elements and they fall in one of the following categories:

  • The stage: Each application has one stage object and it contains all on-screen display objects (i.e. containers or simple objects). This includes objects that the user can't see (e.g. ones that are outside of the stage).
  • Display object containers, i.e. objects that can contain both simple display objects and other display object containers.
  • (Simple) display objects

Read for example Introduction to the Display List (Yahoo developper network) or Creating, Deleting and Accessing Display Objects at Runtime in Flash CS3 if you want to learn how to code adding and removing display objects.

Stage and Timeline

“To summarize: one stage, one root per SWF (which is the main timeline) and that root is an instance of a document class or the MainTimeline class if a document class isn't provided”

Action Script entries in this wiki

Action Script tutorials

(1) In this wiki we teach some Action Script to Flash designers, e.g.:

See the Flash tutorials entry for a full list.

(2) Then we also have "pure" Action Script tutorials for people who wish to learn how to program.

Useful Links pages in this wiki

Links

Most links are in specialized links pages (see just above)

Development environments

Blogs and stuff