简体   繁体   English

Flash AS3-如何将“导入的文本字段”动画片段设置为不可选择

[英]Flash AS3 - how to set Imported textfield movieclip as unselectable

I created a graphic in Flash CS4 that contains text. 我在Flash CS4中创建了一个包含文本的图形。 I embedded the appropriate characters then saved it as a MovieClip into my library. 我嵌入了适当的字符,然后将其作为MovieClip保存到我的库中。 I then exported it to an SWC file. 然后,我将其导出到SWC文件。

In my AS3 code (using Flex SDK/notepad), I then import the movieclip and assign it some mouse events so I can use it as a button. 然后在我的AS3代码中(使用Flex SDK /记事本),导入动画片段并为其分配一些鼠标事件,以便可以将其用作按钮。

Unfortunately, all the text-in-graphics I import this way have the "I" mouse cursor and the text is selectable. 不幸的是,我以这种方式导入的所有图形输入文本都具有“ I”鼠标光标,并且文本是可选的。 This steals the focus from my flash application and is not good! 这从我的Flash应用程序中夺走了焦点,而且不好!

I know when I have a textfield I can: 我知道有文本框时,我可以:

var myButton:TextField = new TextField();
myButton.MouseEnabled = false;

But this has no effect when it's a Movieclip I'm importing: 但这在我要导入的Movieclip中无效:

var myButton:MovieClip = new MyImportedButtonGraphic();
myButton.MouseEnabled = false;  // No effect

// Plus some other things I learned:
myButton.selectable = false;    // also no effect
myButton.MouseChildren = false; // No effect

What am I doing wrong? 我究竟做错了什么?

In the flash ide, select the textField, go to the properties panel and uncheck the button that has the characters 'Ab' in it. 在Flash IDE中,选择textField,转到属性面板,然后取消选中其中包含字符“ Ab”的按钮。 That stops your text being selectable. 这使您的文本无法选择。

If you are setting the movie clip that holds the text to not be mouse enabled, then you need to set both propetries for it, mouseEnabled and mouseChildren. 如果要设置不支持鼠标的文本的影片剪辑,则需要为其设置两个属性mouseEnabled和mouseChildren。 mouseEnabled means that that particular movie clip can't get mouse events, but doesn't affect the movie clip's children (such as the textfield inside it). mouseEnabled表示该特定的影片剪辑无法获取鼠标事件,但不会影响该影片剪辑的子级(例如其中的文本字段)。 mouseChildren means it's children don't register mouse events, they just dispatch from the parent. mouseChildren表示子级不注册鼠标事件,它们只是从父级调度。 To completely disable it, BOTH need to be false. 要完全禁用它,两个都必须为false。


var myButton:MovieClip = new MyImportedButtonGraphic();
myButton.mouseEnabled = false;
myButton.mouseChildren = false;

Since the textfield is a child of the movie clip, the mouseChildren property is what is going to affect it, and you could just set that to false and it would still work. 由于文本字段是影片剪辑的子级,因此mouseChildren属性将对其产生影响,您只需将其设置为false即可继续使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM