`

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

    博客分类:
  • Flex
阅读更多

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 画线 可以给线条增加事件

    为了让鼠标在线条上时显示为手型,我们需要在`myLine`组件上设置`mouseChildren`和`cursor`属性: ```actionscript myLine.mouseChildren = false; // 防止子元素接收鼠标事件 myLine.cursor = "hand"; ``` 4....

    Flex 开发技巧集

    7. **Label控件实现手型图标**:通过设置`useHandCursor`, `mouseChildren`和`buttonMode`属性,可以使Label具有鼠标指针的手型效果,并且像按钮一样响应点击事件。 8. **获取Alert的用户选择**:Alert的`show`方法...

    flex 窗体拖拽,可以自由拖拽,最大化,最小化等等

    这可以通过设置窗体的`mouseChildren`属性为`false`,然后在窗体上添加一个覆盖整个区域的透明薄膜,监听薄膜上的鼠标事件来实现。 在Flex开发中,理解并掌握这些基本的窗体交互技巧是至关重要的,它们能帮助我们...

    画线,对象拖动,自定义鼠标

    本实验聚焦于“画线、对象拖动及自定义鼠标”这些关键功能,这些都是Flash CS4环境中实现用户交互的基础。让我们深入探讨这些知识点。 首先,"画线"在Flash中通常通过AS3(ActionScript 3)编程来实现。AS3是Flash...

    flex 自定义右键菜单

    在Flex开发中,右键菜单是用户交互的重要组成部分,它为用户提供了一种便捷的方式来访问上下文相关的操作。本文将深入探讨两种实现Flex自定义右键菜单的方法:系统右键菜单的扩展以及完全自定义的右键菜单。 1. **...

    as3制作鼠标心型跟随效果

    在本文中,我们将深入探讨如何使用ActionScript 3(AS3)来实现一个有趣的互动效果:鼠标心形跟随。ActionScript是Adobe Flash Professional中的编程语言,用于创建动态内容,如动画和交互式应用程序。这个“鼠标...

    flash游戏中的文本热区导航

    - **自定义鼠标指针**:使用`mouseChildren`和`mouseEnabled`属性控制鼠标指针的变化,或者使用`setCursor()`方法设置自定义鼠标光标。 - **处理点击事件**:在事件处理函数中,根据点击的文本位置执行相应的逻辑...

    AS3+xml下拉菜单_下拉弹出框菜单

    使用`Stage`的`addChild()`方法将弹出框添加到舞台上,并通过`mouseChildren`和`mouseEnabled`属性控制交互性。 5. **XML布局与样式**: XML不仅可以存储菜单结构,还可以包含样式信息。通过解析XML中的CSS样式,...

    flash as3.0代码优化

    - 设置 `mouseEnabled` 和 `mouseChildren` 属性为 `false`,可以降低鼠标事件处理的开销。 ### 5. 定时器与动画优化 - 尽量减少对 `ENTER_FRAME` 事件的监听,合理使用 `Timer` 类,避免过度更新导致的性能瓶颈。...

    (精品word)Flash.as数字拼图游戏代码.doc

    - 设置 `rect.mouseChildren=false` 阻止小方块内的文本接收鼠标事件,避免干扰游戏逻辑。 - 每个小方块都有一个监听器 `rect.addEventListener(MouseEvent.CLICK, dong)`,当点击发生时调用 `dong()` 函数处理...

    Flash优化技巧整理

    **3、当不需要鼠标事件的时候将mouseEnabled和mouseChildren设为false** - **鼠标事件**: 关闭不需要的鼠标事件监听器可以降低CPU负载。 **4、对执行时间太长的非动画内容,优先选择计时器,而非Event.ENTER_FRAME...

    FLASH游戏渲染技术

    - **合理使用事件监听器**:关闭不必要的鼠标事件监听器,如`mouseEnabled`和`mouseChildren`,可以降低系统负担,提高游戏运行的流畅度。 #### 五、综合应用案例 根据文章提供的数据,使用`copyPixels`进行1000次...

Global site tag (gtag.js) - Google Analytics