title: AS3 Accessing Variables of Parent Class From Child
body: <p>i'm trying to assign a parent's variable from the parent's child</p>
  
  <pre><code>//Parent
  public class Main extends Sprite
      {   
      public var selectedSquare:Sprite;
  
      public function Main()
          {
          //inits and adds new Square child class to display list
          }
  ...
  
  -------
  
  //Child
  public function dragSquare(evt:MouseEvent):void
      {
      Sprite(parent).selectedSquare = this; //evil doesn't work!
      parent.addChild(this);
      this.startDrag();
      }
  </code></pre>
  
  <p>i'm receiving this error, but i'm casting parent from displayObjectContainer to a Sprite so i have no idea why it's not working.</p>
  
  <blockquote>
    <p>1119: Access of possibly undefined
    property selectedSquare through a
    reference with static type
    flash.display:Sprite.</p>
  </blockquote>