actionscript 3 - how to access dynamic/static movieclip with linked class? -


hi question still bothering me. looks simple. got movieclips in lib , on stage has link-class "box.as" , linked "circle.as". want access movieclip of box.as circle.as or vice-versa.

public class circle extends movieclip {     private var _circle:movieclip;     private var _box:box;       public function circle()     {         _circle = new movieclip();          if (stage) onstage();         else this.addeventlistener(event.added_to_stage,onstage);       }     private function onstage(e:event = null)     {         _circle = stage.getchildbyname("blue_circle") movieclip;         this.addeventlistener(event.enter_frame,hittarget);      }      private function hittarget(e:event):void     {          if (_circle.hittestobject(_box.mc)) //test if 2 movieclips colliding         { // _box.mc created same _circle             trace("hi");         }      } 

this code ain't workin. , wanted use 1 can access if movieclip wasn't on stage(which has no instance name).
hope can me. thanks.

looks you're close! forgot create new instance of class box. inside public function circle() add

_box = new box(); 

let me know if works. if doesn't, there might wrong linking...

your whole code this

    public class circle extends movieclip {     private var _circle:movieclip;     private var _box:box;       public function circle()     {         _box = new box();         _circle = new movieclip();          if (stage) onstage();         else this.addeventlistener(event.added_to_stage,onstage);       }     private function onstage(e:event = null)     {         _circle = stage.getchildbyname("blue_circle") movieclip;         this.addeventlistener(event.enter_frame,hittarget);      }      private function hittarget(e:event):void     {          if (_circle.hittestobject(_box.mc)) //test if 2 movieclips colliding         { // _box.mc created same _circle             trace("hi");         }      } 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -