如何检测静态文本在AS3? [英] How can I detect StaticText in AS3?

查看:101
本文介绍了如何检测静态文本在AS3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的闪存项目静态文本字段,我需要运行一些code,当鼠标悬停在他们。所以,我想这code

I have StaticText fields in my flash project and I need to run some code when the mouse is hovering over them. So I tried this code

  stage.addEventListener(MouseEvent.MOUSE_OVER, mouseRollOver);
  function mouseRollOver(event:MouseEvent):void {
  var tf:StaticText  = event.target as StaticText;
  if (tf){
  //my code
  }
}

,但它不工作。当我使用动态文本字段和文本字段在var TF取代静态文本,它工作正常。我还以为我能得到这个东西与静态文本字段工作,如果我可以让鼠标的检测并不STATICTEXT为具有一定的文字属性(如选择设置为true)的目标,但有些类型的对象,但我找不到牛逼弄清楚如何做到这一点。无论如何,我需要检测的静态文本字段作为目标莫名其妙。任何帮助将是AP preciated。
在此先感谢

but it doesn't work. When I use dynamic text fields and replace StaticText with TextField in the var tf, it works fine. I also thought that I could get this thing working with static text fields if I could make the mouse detect not StaticText as a target but some kind of object that has certain text properties (like "selectable" set to true), but I couldn't figure out how to do this. Anyway, I need to detect a static text field as a target somehow. Any help would be appreciated.
Thanks in advance

推荐答案

您最好的办法是把静态文本框在一个影片剪辑,然后分配根据各地您code。静态文本框不具有实例名称,并且不能被操纵

Your best option would be to put the static text box in a movieclip, and then assign your code based around that. Static text boxes don't have instance names, and can't be manipulated.

这篇关于如何检测静态文本在AS3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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