Posted By

curiousmedia on 10/15/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

davidino1978


Basic Class Structure


 / Published in: ActionScript 3
 

  1. package {
  2.  
  3. // IMPORTS
  4. import flash.display.*;
  5.  
  6. // CLASS DEFINITION
  7. // must match file name (MyClass.as)
  8. // convention says start with a capital
  9. public class MyClass extends MovieClip {
  10.  
  11. // INSTANCE VARIABLES or PROPERTIES
  12. private var instanceVariable:String = "I'm an instance variable";
  13. public var myProperty:String = "I could be a property";
  14.  
  15. // CONSTRUCTOR
  16. // runs when an instance of MyClass is created
  17. // must match class name
  18. public function MyClass():void {
  19. trace("instanceVariable: "+instanceVariable);
  20. }
  21.  
  22. // METHODS
  23. private function doSomething():void {
  24. trace("myProperty: "+myProperty);
  25. }
  26. }
  27. }

Report this snippet  

You need to login to post a comment.