FlexSpy

昨天写了个小东西,FlexSpy(灵感来自于 SWT Spy )。它可以用来侦测任意鼠标下的MovieClip和TextField。这个工具可以帮助你更深入的了解V2Component的内部构成。

用法很简单:

1
pawaca.debug.FlexSpy.monitoring=true;

这里 下载FlexSpy

ContextMenuManager

In Flex, only top-level components in the application can have context menus. For example, if a DataGrid control is a child of a TabNavigator or VBox container, the DataGrid control cannot have its own context menu.

这是引自Flex文档里的一段话,而且Flash里也是这样,嵌套的MovieClip没法设置menu。我觉得这实在是没道理,在实际应用中,我们很容易碰到需要给嵌套MovieClip设置menu的需求。比如在一个Tree组件中,我们有时会需要根据上下文为每一个TreeNode指定不同的ContextMenu。

不过这种需求在现在MM给的环境中无法直接实现。

于是我开始动手自己写了个ContextMenuManager,目的很明确,就是可以给任意一个MovieClip或者TextField添加相关的ContextMenu。

完整的源码和示例文件可以 从这里下载

ContextMenuManager常规的用法包含以下几步:

  • 从ContextMenuManager中获取一个新的ContextMenu;
1
var cm:ContextMenu = ContextMenuManager.newMenuTemplate();
  • 向ContextMenu中添加ContextMenuItem;
1
ContextMenuManager.appendCustomMenuItem(cm,"pawa!");
  • 把ContextMenu添加到指定的movieclip或者textfield上。
1
ContextMenuManager.setMenu(yourMovieclipOrTextField,cm);

就这样!Enjoy!

I am a firestarter, twisted firestarter

I’m the self inflicted, mind detonator.Yeah, I’m the one infected, twisted animator.