加载变量 stage.loaderInfo 时出错 - AS3

发布于 2024-08-27 12:17:19 字数 569 浏览 4 评论 0原文

我有一个 Document 类,它使用 stage.loaderInfo 从 Facebook 加载变量

var connect:FacebookConnectObject = new FacebookConnectObject( facebook, API_KEY, this.stage.loaderInfo );

但是当我更改 Document 类时(另一个负责我的应用程序的布局),并尝试从我的应用程序中存在的影片剪辑中调用上述内容,使用:

var facebook_class:FacebookAp = new FaceBppkApp addChild(facebook_class) 我收到错误

TypeError: Error #1009: Cannot access a property or method of a null object reference.

我相信错误来自这一行

this.stage .loaderInfo

自从我更改了范围...
我应该如何解决这个问题?

I have a Document class that loads variables from Facebook with the use of stage.loaderInfo

var connect:FacebookConnectObject = new FacebookConnectObject( facebook, API_KEY, this.stage.loaderInfo );

But when I change the Document class (with another one responsible for the layout of my app), and try call the above from a movieclip that exists in my application with the use:

var facebook_class:FacebookAp = new FaceBppkApp
addChild(facebook_class)
I get error

TypeError: Error #1009: Cannot access a property or method of a null object reference.

I believe the error comes fro this line

this.stage.loaderInfo

since I changed the scope...
How I am supposed to fix that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枉心 2024-09-03 12:17:19

根据 Devonair 的帖子:当人们遇到 1009 错误的问题时,100 次中似乎有 99 次是因为 stage 属性无法访问。

所以我使用了这个片段

public function start () {
如果
{(阶段)init();}
别的
{ addEventListener(Event.ADDED_TO_STAGE, init);
}
}

私有函数 init(event:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// 其他一切...
}

如果某人遇到同样的问题...

According to a post by Devonair: Seems 99 times out of a 100 when people have a problem with a 1009 error, it's because the stage property is inaccessible.

so I used this snippet

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

private function init(event:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// everything else...
}

In case sb has the same problem...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文