views:

763

answers:

1

Hello,

I have a child class that is loaded into the parent class when the swf begins, like so:

var myvar = 'hello';
public function Parent()
{
     this.child = new Child();
};

How can I retrieve the variable 'myvar' from within child?

+1  A: 

Child has no reference to the parent, so there is no way to retrieve myvar.

You could create child like this:

public class Child
{
   private var parent:Parent;

   public Child(parent:Parent)
   {
       this.parent = parent;
   }
   ...
}

This will allow the child to access it's parent through it's parent property and will be able to see all the public members that belong to parent.

CookieOfFortune
I was hoping there was some other way but... thanks! I will do this then.
thekevinscott