开发者

Getting Stage from within a loaded SWF

For the scenario lets consider Car to be the highest SWF(stage) in开发者_StackOverflow社区side 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?


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.
}


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜