flash cs4组合框组件完全忽略样式和事件
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的情况,发现如果我在 ActionScript 中创建组件而不是通过可视化设计工具,那么在代码中对组件进行更改就可以了。
因此,我从 .FLA 文件中删除了该对象,并在关联的 .AS 文件中创建了它,如下所示。
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.
问题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.