Creating Custom Classes And Packages In AS3
Custom classes are one of the new features in AS3 and they are very useful to competent Actionscript 3.0 coders.
The main idea of the custom class is just like that of a custom function. Both of which were designed to:
- Help organize code
- Rid of the need for repeating code
- Increase application performance
On a very basic level, both classes and functions both do this, however classes allow the user to be much more dynamic with there code.
An empty class looks like this:
The order of code for a class looks like this:
1.) Declare ‘package’
2.) Imports (Everything needs to be imported in a package / class)
3.) Declare class name + its parent type (”MovieClip, Sprite, EventListener)
4.) Main function (Run on class initiation)
This is the basics of custom class syntax, in the next tutorial, i will explain the use of these classes and how the improve you’re coding.