title: flash as3 - understanding how to pass parsed XML data on to classes
body: <p>I've traditionally all my as3 code in one included .as file, not as packages / class files, but I'm trying to make that transition. I'm a little confused about how to pass information back and forth among class files though. For example, what I'm trying to make is a sort of node diagram where clicking on a certain node will sprout out its child nodes, and clicking on a child node will sprout out its children, etc. I have a main class, Main.as, which I was going to make parse an XML document and store an array of all the relevant data for each node (things like a title, link, etc). Then I have a class file called Node.as which actually builds the node, adds it to the stage, and sets up its listeners and the motion tweens.</p>
  
  <p>My question is - if all the information for the nodes is stored in Main.as, but the click handling is done in Node.as, how does Node.as know what attributes to assign to each added node (i.e., how does it access the array from Main.as to assign properties to the clips created)?</p>
  
  <p>Here's a sample code structure:</p>
  
  <p>Main.as:</p>
  
  <pre><code>package  
  {   
      public class Main extends MovieClip  
      {  
  
          public function Tree()  
          {  
              initTree();
          }
  
          public function initTree(){
              parseXML();
              var firstNode:Node = new Node();
              addChild(firstNode);
          }
      }  
  }
  </code></pre>
  
  <p>Node.as:</p>
  
  <pre><code>package  
  {  
      public class Node extends MovieClip  
      {   
          public function Node()  
          {  
              drawNode();
          }
  
      private function drawNode(parentNode = null){
          //draw the node shape
          //add the shape to a movie clip
          //assign listeners to the movie clip
          //add movie clip to the stage
      }
  
      private function nodeAdded {
          //position the node
          //animate the node
      }
  
      private function nodeOver (e:MouseEvent):void {
          //fetch the information for this node from the XML in Main.as - how do I do this?
      }
  }
  </code></pre>