PDA

View Full Version : What's the best way to use a class with AS3?


diogo
07-24-2006, 11:10 PM
I have always used classes in AS2 without any problem, but now I don't know exactly what's the best way to use them with AS3.

In some examples in the references, I see that the class is created inside a package (no doubt about it), but all is configured INSIDE the class, and not in the FLA, as I use to do with AS2.

The question is: should I configure everything in the .as file and just execute it in the FLA or pass the class' paramaters in the FLA (as before)?


thanks in advance.

astgtciv
07-25-2006, 03:06 AM
Well, as I understand it, you can certainly still do things the same way as in AS2. You do have the option, however, to associate a "Document Class" with your entire fla. This class must extend the flash.display.Sprite class. E.g., in the Flash 9 Alpha Preview, if you go to Publish Settings, and click on the Setting button to the right of "ActionScript 3.0", at the top you can specify the Document Class. If you do specify it, when the Flash Player will load your swf, it will add an instance of your Document Class as a child of the Stage object (the Document Class will be associated with the Sprite for the whole fla). You can perform all the initialization directly in the Document Class.

diogo
07-25-2006, 05:12 PM
Thanks astgtciv, now I know what is the best way =]