Hi guys, yesterday friend of mine came to me and ask if I could teach him basics of ActionScript 3.0, He didn’t have much experience with flash but while a go he did some basic stuff with timeline and as2. So I though it will be cool to make series of articles/tutorials about basics of AS3. This series will be perpoused for people who have some experience with flash, but don’t worry if you don’t know much I think it wont be hard for you to fallow along ;)
I started to learn AS3 a year ago, before I had few year experience with AS2. I saw some tutorials on the web and I started to play with it, after a year of developing in AS3 I think it’s much more intuitive then AS2 (AS2 it’s like pseudocode :P).
The main reasons why I switched to AS3 are:
- full oop
- ease of use
- logic hierarchy (Object, MovieClip, Sprite, etc.)
- I think eventually you have to go with the progress, sooner = better :)
- I always learned from Lee Brimelow, he started to make as3 tutorials :D
The first think you will need to learn AS3 is language reference in your bookmarks, I always use it, before googling for answer first check the reference. Many times I have found answers right there. The second good think about language reference is that you can check how thinks really work, and discover some usefull methods etc. (if you want desktop language reference you can download a little air app made by guys from BigSpaceShip, download here) What if you didn’t found an answer in the reference? The you will have to check in other places there are plenty of forums, blogs and sites that will help you (at the end of this article I will put some useful links).
Now we can get to serious stuff.
In AS2 you could put the code everywhere, on the MovieClip, Button, frame… AS3 is different you can only put code into frame or into external class. To develop in AS3 you need to use Flash CS3 or greater. The new versions of Flash has this great option called document class it is really good practise to use it! Instead of writing the code for example in the firs frame of main timeline you can create a ActionScript 3 class and use it as it was the code from your first frame. If you link class with flash using the document class you can call item that are place directly on the stage or in the library and you want get any error! How cool is that? For those of you who dont know the structure of a Class here it is:
package{ /*/first the package keyword, if your class in pleaced in some folder structure you should put the package file path after the package keyword for example 'package com.massiveProCreatio' /*/ import flash.display.Sprite; public class MyClass extends Sprite{ /*/here we have declaration of our class cald 'MyClass', extends says the flash that our class is extending the movie clip/*/ public function MyClass(){ /*/after the definition of our class we have class constructor this function will be cald each time this class is instantiated/*/ } } }
If you link this class to your fla and run this nothink will happend but if you put in the constructor this:
trace("The document class works");
you should see in the output “The document class works”. Class can have multiple function, you can call them from the costructor or from other classes. It’s much more lucid to use document class insted of writing code in the keyframe. The other adventage of using the document class is that you can use external code editors for your AS. I really recomend the Flash Develop it’s free and it has really good code hinting and highlighting, the only minus of FD is that there is no mac or linux version :(
Thats it for today, below I am pasting some usefull links (there will be more of them in next parts).
In part two we will talk about Events, Tweener, and we will make simple image based menu :)
Usefull links:
- AS3 Language Reference.
- Adobe Developer Connection (you can find there many articles and video tutorials).
- The FlashBlog, blog by Lee Brimelow.
- gotoAndLearn, site by Lee Brimelow you can find there really great tutorials and forum.
- Kirupa forums.
- ActionScript.org forums.
- Tweener.
- AS2 to AS3 migration – for those of you have want to switch from AS2 to AS3
I hope you enjoyed this article, if you have any suggestion or questions please comment!







[...] I posted some usefull links but we havent done anythink practical (if you havent read the part one here it is) :) In part 2 we will make a simple AS3 menu that uses the Tweener for [...]
Good tutorial. I downloaded and installed Flash Develop, thanks for the link :)
Here’s the ultimate resource link for flash/actionscript documentation:
Adobe – Flash CS3 Resource
And for open-source flash/actionscript resources:
Open Source Flash
[...] some text data. If you haven’t read the previous parts of AS3 Basics here they are: part1, part2, also if you don’t know what is XML check out [...]
[...] Introduction. 2. Creating simple menu – using events and Tweener. 3. Loading xml and reading data from [...]
[...] listeners and tweener ( if you are not fallowing along I recomend to read the previous tutorials: part 1, part 2 , part 3). Now it’s time to combine this knowlage in one project. We will make simple [...]
[...] ActionScript 3.0 Basics part 1. ActionScript 3.0 Basics part 2. ? Simple Menu, using tweener Tutorial. ActionScript 3.0 Basics part 3 -loading xml data. ActionScript 3.0 Basics part 4 ? news reader component. [...]
[...] ActionScript 3.0 Basics part 1. ActionScript 3.0 Basics part 2. – Simple Menu, using tweener Tutorial. ActionScript 3.0 Basics part 3 -loading xml data. ActionScript 3.0 Basics part 4 – news reader component. [...]
[...] ActionScript 3.0 Basics part 1. ActionScript 3.0 Basics part 2. – Simple Menu, using tweener Tutorial. ActionScript 3.0 Basics part 3 -loading xml data. ActionScript 3.0 Basics part 4 – news reader component. [...]