Flex中的(handCursor)手型鼠标及mouseChildren属性

Flex里很多控件的手型鼠标可以用如下方式实现:

buttonMode="true" 或 useHandCursor="true" 或者两个一起。

但是Label和其他一些控件我一直搞不定。

 

今天终于发现,Label需要设置为:

buttonMode="true"  mouseChildren="false"

 

 

去帮助里找到了mouseChildren这个属性。大意如下:

mouseChildren这个属性控制的是该控件是否能够让用户通过鼠标来交互,即触发鼠标事件。默认为true。

 

如果想用自定义的Sprite作为button使用,就可能需要这个属性。因为Sprite中可能会包含其他子控件,为了让该Sprite作为一个整体来响应交互动作,就需要屏蔽其子控件的MouseEvent响应。也就是需要把子控件的mouseChildren=false。

 

这个属性和Label的关系, 难道说明Label本身是一个特殊的组合的Sprite?

 

 

 

mouseChildren property

mouseChildren:Boolean   [read-write]

Determines whether or not the children of the object are mouse enabled. If an object is mouse enabled, a user can interact with it by using a mouse. The default is true .

This property is useful when you create a button with an instance of the Sprite class (instead of using the SimpleButton class). When you use a Sprite instance to create a button, you can choose to decorate the button by using the addChild() method to add additional Sprite instances. This process can cause unexpected behavior with mouse events because the Sprite instances you add as children can become the target object of a mouse event when you expect the parent instance to be the target object. To ensure that the parent instance serves as the target objects for mouse events, you can set the mouseChildren property of the parent instance to false .

No event is dispatched by setting this property. You must use the addEventListener() method to create interactive functionality.

你可能感兴趣的:(Flex)