Basic Package and Class Creation / Extend


/ Published in: ActionScript 3
Save to your folder(s)

How to create a basic class in AS3 and extend it if needed.


Copy this code and paste it in your HTML
  1. //In myBaseClass.as
  2. package {
  3. public class myBaseClass {
  4. public function sayHello():void {
  5. trace("hello");
  6. }
  7. }
  8. }
  9. //In mySubClass.as
  10. package {
  11. public class mySubClass extends myBaseClass {
  12. public function sayGoodbye():void {
  13. trace("goodbye");
  14. }
  15. override public function sayHello():void{
  16. trace("This is a trace!");
  17. }
  18. }
  19. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.