flash cs4组合框组件完全忽略样式和事件

发布于 2024-08-21 03:20:28 字数 453 浏览 7 评论 0原文

我在 flash cs4 中有简单的组合框组件,我尝试添加这样的事件监听器,

mycombo.addEventListener(Event.ADDED_TO_STAGE, added);

function added(e:Event):void
{
trace("HI");
}

即使我手动或通过 AS 在舞台上拥有该组件,也永远不会被调用,但是如果我向 MouseOver 添加监听器,它就可以工作,为什么 ADDED_TO_STAGE 事件不起作用,而且我对 textFormat 样式也有问题,如果我使用它

mycombo.setStyle("textFormat", tf);//suppose tf is a TextFormat object

也不起作用,但如果我将该行放在 MouseOver 事件中,它会起作用,这是为什么?请帮忙谢谢!!

I have simple combobox component in flash cs4, I try to add and event listener like this

mycombo.addEventListener(Event.ADDED_TO_STAGE, added);

function added(e:Event):void
{
trace("HI");
}

never get called even if I have the component in the stage manually or via AS, but if I add a listener to MouseOver it works, why the ADDED_TO_STAGE event don't work, also I have a problem with the textFormat style if I use

mycombo.setStyle("textFormat", tf);//suppose tf is a TextFormat object

doesn't work too, but if I put that line inside the MouseOver event it work's why?? please help thanks!!

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

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

发布评论

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

评论(2

烟凡古楼 2024-08-28 03:20:28

我遇到了同样的情况,发现如果我在 ActionScript 中创建组件而不是通过可视化设计工具,那么在代码中对组件进行更改就可以了。
因此,我从 .FLA 文件中删除了该对象,并在关联的 .AS 文件中创建了它,如下所示。

var ddlQF:ComboBox=new ComboBox();
this.addChild(ddlQF);
ddlQF.move(444,191);
ddlQF.setSize(284,40);
ddlQF.rowCount=10;
var myFormat:TextFormat = new TextFormat();
myFormat.font = "Georgia";
myFormat.size=16;
ddlQF.setStyle("textFormat",myFormat);

I had the same situation and found that if I created the component in ActionScript rather than through the visual design tool then making changes to the component in code worked.
So, I deleted the object from the .FLA file and created it in the associated .AS file instead like this.

var ddlQF:ComboBox=new ComboBox();
this.addChild(ddlQF);
ddlQF.move(444,191);
ddlQF.setSize(284,40);
ddlQF.rowCount=10;
var myFormat:TextFormat = new TextFormat();
myFormat.font = "Georgia";
myFormat.size=16;
ddlQF.setStyle("textFormat",myFormat);
七颜 2024-08-28 03:20:28

问题1 原因:

ADDED_TO_STAGE 似乎可以发生在触发器之前。

来自 https://www.adobe.com /livedocs/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html#ADDED_TO_STAGE

DisplayObject 实例直接或通过添加 DisplayObject 实例所在的子树添加到舞台显示列表中包含。如果直接添加 DisplayObject 实例,则添加的事件发生在该事件之前。

问题 2 原因:

同样,我相信该事件是在事件触发之前发生的。因此样式永远不会被处理。

Problem 1 Reason:

It appears that ADDED_TO_STAGE can occur before the trigger.

From https://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/events/Event.html#ADDED_TO_STAGE

The DisplayObject instance being added to the on stage display list, either directly or through the addition of a sub tree in which the DisplayObject instance is contained. If the DisplayObject instance is being directly added, the added event occurs before this event.

Problem 2 Reason:

Again, I believe the event is occurring before the event trigger. Thus the style never gets processed.

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