Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.61 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Calling a function from one class, from another
  2. class Sledge {
  3.    private var main:Main;
  4.    function Sledge(main:Main) {
  5.       this.main = main;
  6.    }
  7.    function doSomething():void {
  8.      main.runSomeFunction();
  9.    }
  10. }
  11.        
  12. class Main {
  13. private var sledge:Sledge;
  14.    function Main() {
  15.       sledge = new Sledge();
  16.       sledge.addEventListener("mainDoSomething", doSomething);
  17.    }
  18.    private function doSomething(e:Event):void {
  19.      // .... do stuff
  20.    }
  21. }
  22. class Sledge extends EventDispacter {
  23.    function Sledge() {
  24.    }
  25.    public function doSomething():void {
  26.      dispatchEvent(new Event("mainDoSomething"));
  27.    }
  28. }