AS3 Tutorials - Language Fundamentals

Hi. My name is Martin Legris and I thought that I would spend some time and create a site that offers a directory of the best resources to learn ActionScript 3 (all flavors) quickly and effectively. I have some nice ideas for this site, and I will work on it when I get the time. For now, I started to gather content, so here is pure content (and nothing else!). If you would like to propose a tutorial, please email me at mlegris _(at)_ newcommerce {dot} ca. Thank you! 

-] Language Fundamentals [-

Passing Parameters to ActionScript 3 SWF

This tutorial covers how to pass parameters to a SWF file and get access to them from ActionScript 3.
[Beginner] by Martin Legris

Go beyond the flash bitmap limitations (2048 x 2048)

I think everybody who has worked with BitmapData in ActionScript knows about the 2880 pixel limitation of the Flash Player. Fortunately Adobe decided to rise this limit in Flash Player 10, I think something about 4000px.

Last week I visited the Flash Forum Conference in Cologne which was btw. great. A lot of inspiration and cool stuff. In his presentation Mario Klingemann talked about »Andre Michelle’s Huge Bitmap hack«. The basic idea is to embed or load a large png and create a BitmapData by cloning it. The same approach can be found here.
[Beginner] by Kirupa Chinnathambi

Getting Started with ActionScript 3.0 in Adobe Flash CS3

This tutorial is the must for every AS3 newbie, no matter what experience level you have (the more experienced, the faster you get through it!).
[Beginner] by Trevor McCauley

Errors (Exceptions) is AS3

One thing you may notice about ActionScript 3 how error prone it is or, rather, how error prone it perceives you to be. You'll see a lot more errors, not only during compile, but also runtime. ActionScript 3 is much less lenient in letting you get away with mistakes or code conflicts. Whereas ActionScript 1 and 2 may silently fail or ignore many errors, ActionScript 3 will be sure to let you know something went wrong.
[Beginner] by Trevor McCauley

Data Typing and Casting in AS3

ActionScript 3, on the other hand, supports not just compile-type type checking, but runtime type checking as well. If a conflict exists with types during runtime in ActionScript 3, a runtime error will be thrown. In general, this is a good thing. But it can also require that you sometimes massage your variable typing to prevent unwarranted errors. One thing about ActionScript 3 is that there are a lot more kinds of object types, or classes. Usng the MovieClip class as an example, it now inherits from Sprite, DisplayObjectContainer, InteractiveObject, DisplayObject, EventDispatcher, and Object. In ActionScript 2, MovieClip only inherited from Object. What this means is that now MovieClip can be used as a value for any variable with any one of these types since in addition to being a MovieClip instance, MovieClip instances are also instances of those type (since they are inherited types).
[Beginner] by Trevor McCauley

AS3 Tutorial: Creating a Slideshow

An Actionscript 3 (AS3) tutorial aimed at AS2 developers for creating a flash slideshow.
[Beginner] by Armand Niculescu

Undertand ADDED_TO_STAGE Event

You are about to meet an event that is not used as it would deserve, because – sad but true – programmers do not use it that much. Let me give ADDED_TO_STAGE event its moment of fortune and fame, and you will never ever live without it.
[Beginner] by Emanuele Feronato

Building a FPS Meter

Simple one but useful, build your own FPSMeter!
[Beginner] by Keith Peters

Order of Operations in ActionScript

This tutorial breaks down operation order of ActionScript into three parts: object life cycle, frame execution, and events. Frame execution is central to all of these, especially when considering timeline usage in Flash. It is the repeating process through which a SWF runs, creating objects, dispatching events and rendering the screen. Though much of the focus here is given to the timeline - as generated by the Adobe Flash Professional authoring tool (Flash Pro) - much of the content can still be applied to projects with a more ActionScript-centric approach.
[Intermediate] by Trevor McCauley

Embedding Resources with AS3

Someone recently asked about "code injection" using AS3. Code injection comes from MTASC, where the byte code is added to an existing SWF. The person wanted to create a Flash 9 SWF with the Flash 9 AS3 preview IDE, and use mxmlc.exe to inject code into it. This is not possible, but there are some equally powerful alternatives using embedding in AS3. As this whole AS3 thing is fairly new to many, I thought I'd explore it a bit and post some info. Using the AS3 compiler, you obviously don't have a library for storing movie clips, graphics, text field, bitmaps, etc. So how do you get these into a SWF? Using the Embed tag.
[Intermediate] by Keith Peters

Preloading in AS3

Preloading in ActionScript 3 - Learn the cleanest, most reliable method of preloading your ActionScript 3 movies.
[Intermediate] by Lee Brimelow

Sharing Fonts in ActionScript 3.0 - Part 1

In this tutorial series, you learn how to use the new Font class in ActionScript 3.0 and Flash Player 9. The Font class enables you to embed one or more fonts in a Flash movie (SWF file), and reuse the font with other SWF files. In this tutorial, you learn how to create a font SWF file and load it into another Flash movie.
[Intermediate] by Robert Reinhardt

Creating an Image Reflection

In this simple example, we show how to create an image reflection in AS3 and Flash.
[Intermediate] by Dan Gries

Getting Started with pure AS3 & MXMLC

If you're anxious to get started with ActionScript 3 but don't want to have to learn Flex or MXML, the form of XML Flex uses to design applications, this tutorial is for you. Here you will learn how to use the command line compiler (mxmlc.exe for the Windows platform) to compile and create SWF files that use ActionScript 3.
[Intermediate] by Trevor McCauley

Flash Preloader for the Main Timeline

If we want to create movies, we sometimes may need a preloader for images and other byte-intensive objects. To create a preloader in Flash 9 using AS3 is slightly different from other Flash versions, although certain principles are the same. The class, which we use to monitor preloading is the "LoaderInfo" class. This class can also be used to preload objects within a movie. The movie below shows a simple preloader.
[Intermediate] by FlashScript.biz

ActionScript 3 Performance Testing

Learn how to use Grant Skinner's PerformanceTest class to test your code's speed.
[Intermediate] by Lee Brimelow

Declaring and using package functions

I was doing something, I forget what it was now, but it got me curious about functions defined in some of the flash player native packages. The flash.net, flash.profiler, flash.system, and flash.utils packages all have functions defined in the package itself rather than in a class as static methods. This got me wondering if it was possible to do this with my own packages. Typically what’s defined in a package file is a class or interface which I thought were the only allowed but apparently not.
[Intermediate] by David Chang

Implementing your own callLater function in AS3

Although I am not a big fan of the CallLater function in Flex's UIComponent, I must admit that it is sometimes handy. Here is how you can implement your own CallLater function, this code can be incorporated inside of any class, enabling you to add functions that are called after the current thread of execution has been depleted.
[Advanced] by Martin Legris

SWF TextField Factory — Dynamically Loading Fonts in AS3 using Flex SDK 3.4

Now the next challenge, loading fonts dynamically. Euh, well, I used to do it from a FLA, was easy. But using the Flex SDK 3.4 it seems that some things changed. After HOURS of playing around, I ended up with the following system:
- embed the font inside of a swf that contains a Main class + the font class
- create a function that will spawn textfields already using the font inside this Main class

Although this system has some limitations, it works beautifully.
[Advanced] by Martin Legris

Event Bubbling

AS3 has a new feature, which is called bubbling. As an example check the movie below and click on the menu buttons. In the right menu you see the negative and positve effect of bubbling.
[Advanced] by FlashScript.biz

Creating 3D Reflections in CS4

In this How-To, we show how to create a simple image reflection that can be rotated in 3D. We use a gradient mask and the 3D methods available in Flash Player 10 to accomplish the effect.
[Advanced] by Dan Gries

Ethical SWF Decompiling

Learn how decompiling can help you understand what Flash does behind the scenes.
[Advanced] by Lee Brimelow

Get the class used to create an object instance in AS3

Sometimes, you want to know the datatype of an object at runtime. The most common thing to do in ActionScript 3 is use the is keyword to see if an object is an instance of a specific class. For example, you use exampleObject is Sprite to see if something is a Sprite (or any subclass of Sprite). However, there are times when you want to use the actual class in your code to create a new instance, or to do something a little more arcane. There are a couple simple ways to access the datatype of an object and place it in a variable.
[Advanced] by Josh Tynjala

Clean-up and unload child SWFs

If you have a SWF that you know will be loaded into a parent SWF, then it's your responsibility as a developer to properly clean up after yourself when your child SWF is unloaded. Certain activities will keep your SWF in memory long after the unload() method is called on the Loader object that holds your child SWF, and there's a good chance that you'll have created a memory leak if you don't take care of things properly.
[Advanced] by Josh Tynjala

AS3 Runtime Font Loading

Here’s a little experiment with loading fonts dynamically at runtime. So what’s this good for? Well let’s say you have a flash application where you want to allow users to customize the text formatting for some text box. Typically you would provide a small set of fonts which would all get embedded into the swf but this isn’t very flexible or ideal. Changing font’s or adding new one’s require rebuilding the swf. Also if only one or two fonts get used then all the other extra fonts do nothing but bloat the swf size. For this situation, it would be ideal to externalize the fonts and only load in the one’s needed.
[Professional] by David Chang

AS3 logging with Log4j

There are several things I miss about FlexBuilder…the debugger, authoring-time error checking, code assistance, and the quick compiles to name a few. But perhaps the first thing you’ll miss when just using the free Flex SDK is your basic trace output window. Initially I had written a simple Ruby script to handle tracing to a terminal window. This was fine for awhile but as some of my projects grew bigger, I wanted more control over logging.
[Professional] by David Chang