There are thousands of resources for this question, but I recently began as a complete beginner so kind of know how you feel about reading jargon relating to the question “What is a Class?”.
Firstly, a Class is a separate file. You need to write a Class in a new .as (actionscript) file.
Basically, what they do is tell your flash movie everything it needs to know about any element within it. You make classes for elements in your movie. They link and control Movie Clips, the actual Document and just about any other object you want to create in your Flash Project.
The best use for a class is when it contains actions that you can see yourself reusing.
For example; say you have a few different characters that you want to make run accross your screen. If you make a Class called RunAccrossScreen, you can right click any object in your library and use ‘Linkage’ to use the RunAccrossScreen class on that item. If using it on one item from your library you would leave the base Class set what it was on and type “RunAccrossScreen” into ‘Class’. You can use the class as many times as you want however, providing you type it in as the base Class.
For information on writing a Class file continue below:
———–
You store Classes in Packages. Packages are literally packages for what your about to type in. They are also used if you need to organise a complex system of Classes.
Its a bit like sending christmas cards. Say you have one multipack of cards with father christmas, snowmen and presents on…. and another multipack with images of things like Jesus, Wise Men etc. You have bought those cards for two different families. One is religious and Christian, the other is not so religious.
So your going to write in all of these cards with different names and messages for individual people. These could be considered your classes.
Now consider (but not strictly do in real life!), your sending these different cards to only two different addresses. In our personal, kind and gesturous human way we would now foolishly put each and every individual card into its own envelope and send every card to the same address. However, in programming you would need to be a little more practical, organised and cold, but hopefully you won’t… feel… the same about humans and scripts for computers. Consider the above situation again. The most practical thing to do would be to take all of your cards and organise them (all) into just two envolopes with two different addresses and send them off.
Thats how Packages and Classes work. They are a way of organisation and practicality.
———–
Each Class you write is a separate (.as) file, however a Package can be a container of many different (.as) files.
This works as files/ directories on your computer work. You have a Pictures folder, which probably holds lots of different pictures. In the same way, Packages are files on your hard drive that contain different (.as) files.
———–
I won’t go into it to deeply because there are good resources out there for this part, but this is the code used to create a Package/ Class:
For this to make sense and to gain more from this example, I suggest you copy and paste it into your ActionScript editor to read.
package character { /*You always put package { at the start of your Class file. You can name it (ie ‘character’) optionally.*/
import flash.Display.MovieClip; /*If your using this class on a movie clip you need to import the MovieClip class.*/
public class CharacterMove extends MovieClip { /*You need to make the class either private or public. Add a class name ‘ie CharacterMove. Then tell it that it is going to extend the MovieClip Class’s functionality.*/
public function() { /* public function is a function that is automitcally carried out every time you use the class*/
target.x + = 40; /* for example, every time I use this Class, it will make every item its ever linked to move 40 pixels accross*/
}
}
} /* close the braces!*/
———–
Thats it, I hope I helped you understand Classes a little more!
For help and some great references try visiting:




