flash - How can I link a reference to a movieclip in another AS3 file? -


in main as, using movieclip container despite of stage. in file, want take container reference addchild (such bullets etc) it, don't know how write code.

if addchild in current (sub)as, it's working, it's problem removechild.

don't know if right but....

you have container in main class , want access class, right?

i guess need globals.as this

globals.as // name it...  package {    public class globals extends object {        public static var your_reference_var:movieclip; // static var     }  } 

you need assign your_reference_var movieclip in main class. anywhere in project have access movieclip.

package {   import globals.as;   import flash.display.sprite;    public class gameengine extends sprite  {       public function gameengine () {          addeventlistener (event.added_to_stage, _onaddedtostage);       }        private function _onaddedtostage (evt:event):void {          removeeventlistener (event.added_to_stage, _onaddedtostage);           //when access movieclip access          globals.your_reference_var.alpha = 0.5;       }    }        } 

now use addchild/removehild this

var spr:sprite = new sprite(); globals.your_reference_var.addchild (spr); //remove child globals.your_reference_var.removechild (spr); 

i hope helps.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -