views:

29

answers:

2

Hi,

For the scenario lets consider Car to be the highest SWF(stage) inside I load tyres. Inside tires I have rims. Now if the rims need to be positioned relative to the stage (car body) how can I do that? Inside rims if I write stage and load it results in an error.

Any Ideas?

A: 

from the child swf you can use this to access any variable/function or prop of your root app. Hope this solves your problem.

if(this.parent.root != stage)
{
MovieClip(this.parent.root).rootVar;
}
dome
+2  A: 

in the constructor for rims, first test to see if it's been added to stage:

public function Rims() {
    if (stage) init();
    else addEventListener(Event.ADDED_TO_STAGE, init);
}

public function init(e:Event = null) : void {
    removeEventListener(Event.ADDED_TO_STAGE, init);
    //you can access stage now.
}
jonathanasdf