AS3不能设置复选框标签 - 需要知道什么时候是装 [英] as3 can't set checkbox label - need to know when it is loaded

查看:164
本文介绍了AS3不能设置复选框标签 - 需要知道什么时候是装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个FLA,和高级ActionScript设置下,我们有

We have a fla, and under "Advanced Actionscript Settings", we have

自动声明舞台实例

选中。

然后我们有一大堆的这些声明在我们的文档类的类层次:

We then have a bunch of these declarations at the class level of our document class:

public var spouseCheck:CheckBox;  

如果我将在我的构造spouseCheck.label =嗒嗒,这是行不通的。不过,如果我以后设置它,(当另一事件发生),它的工作。这意味着该复选框被当时完全加载。我怎样才能把一个事件侦听器的复选框,这样我就知道什么时候是完全加载,我可以设置标签?谢谢!

If I set spouseCheck.label = "blah" in my constructor, it does not work. However, if I set it later, (when another event happens), it does work. This implies that the checkbox is completely loaded at that time. How can I put an event listener on the checkbox so that I will know when it is completely loaded, and I can set the label? thanks!

推荐答案

在你设置 spouseCheck.label =嗒嗒类的构造函数,删除该行并加入这一行:

In the constructor of the class where you set spouseCheck.label = "blah", remove that line and add this line:

spouseCheck.addEventListener(Event.ADDED_TO_STAGE,init);

然后创建初始化函数:

Then create the init function:

function init(e:Event):void {
    spouseCheck.label = "blah";
    spouseCheck.removeEventListener(Event.ADDED_TO_STAGE,init);
}

这事件被触发时,spouseCheck是在图像显示(阶段),并应确保它已经准备好。

That event is triggered when spouseCheck is on the displayList (stage) and should ensure it's ready.

这篇关于AS3不能设置复选框标签 - 需要知道什么时候是装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆