title: How do I pass reference of an initialised object from one class to another class, to add (addChild) to display list?
body: <p>I created this simple example
  because I was using a more complex class, a menu item that I wanted to initialise all the settings in the Main class and then add it in in the Game class (and updating it) when needed (both classes are separate)</p>
  
  <p>Class: Main (document class, is (ideally) where everything is initialised/created)</p>
  
  <pre><code>    public class Main extends MovieClip
      {
              //testing passing on reference to Game
          private var testBitmap:Bitmap;
          private var testBitmapData:BitmapData;
          private var testArray:Array;
  
              public function Main():void
              {
                  testBitmapData = new BitmapData(256, 256, false, 0xCCDDEE);         
                  testBitmap = new Bitmap(testBitmapData);            
                  testArray = [];
                  testArray.push(testBitmap);    //Array for reference
  
                  game = new Game(540, 960, testArray); 
                      //create Game class, pass reference to Object
                  game.x = 0;
                  game.y = 0;
              }
       }
  </code></pre>
  
  <p>Class: Game (created by document class, is (ideally) where everything runs)</p>
  
  <pre><code>    public class Game extends MovieClip
      {
  
              private var testingArray:Array
  
              public function Game(gameWidth:int, gameHeight:int, testArray:Array):void
              {
                      this.testingArray = testArray;  //assign to local Array and access
                      addChild(testingArray[0]);  
               //addChild to Game from an item intialised in Main, doesn't work &gt;___&lt;
              }
      }
  </code></pre>
  
  <p>.</p>
  
  <p>.</p>
  
  <p>.</p>
  
  <p>the thing is, in my original Game class; it receives an initial bundle of cached BitmapData and a list Array that tells it which BitmapData it needs to cycle through
  cut-down here (and that reference only for updating works (if I addedChild in Main already):</p>
  
  <pre><code>    public function Game(gameWidth:int, gameHeight:int, cachedBitmapClipArray:Array)
      {
  
              this.cachedBitmapClipArray = cachedBitmapClipArray;
  
  
              private function update():void
              {           
                  for each (tempCachedBitmapClip in cachedBitmapClipArray)  
                  {
                      tempCachedBitmapClip.updateCurrentTile();   
            //but updating through the reference to an item initialised in Main works !!
                  }
              }
  
      }
  </code></pre>
  
  <p>.</p>
  
  <p>how do I make the reference and passed in objects (or have access to) behave as in the original instance ?? (being able to addChild)</p>
  
  <p>i.e. can objects cross 'scopes' (??) or should objects only be controlled (instantiated) in the class where they have been initialised</p>