易截截图软件、单文件、免安装、纯绿色、仅160KB

flex tree 添加右键菜单

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12">
<mx:Script>
<!--[CDATA[
import mx.controls.Alert;

public var newBuildMenuItem:ContextMenuItem;//菜单项变量


private function init(): void//初始化函数
{
createTreeMenuItem();
tree.contextMenu = getTreeContxtMenu();
}
public function createTreeMenuItem(): void//菜单项创建函数,并添加菜单监听器
{
newBuildMenuItem = new ContextMenuItem("新建");
newBuildMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, newBuildHandler2);
}

private function getTreeContxtMenu(): ContextMenu//将菜单项目添加到菜单中
{
var contextMenu: ContextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
contextMenu.customItems.push(newBuildMenuItem);
return contextMenu;
}
public function newBuildHandler2(event:Event):void//点击菜单执行函数
{
Alert.show("这是新建的菜单点击后执行的函数");
}
]]-->
</mx:Script>
<mx:Tree id="tree" x="31" y="10" creationComplete="init()"></mx:Tree>

</mx:Application>
为tree添加右键菜单,也可为其他任何控件添加,但暂时没法去除右键自带的菜单项,虽然网上有办法去掉,但是感觉麻烦,大家又好办法提出来啊


相关文档:

update Flex TreeGrid

Summary:
在DataGrid中显示层级结构,google了一下,找到flexlib中的TreeGrid。把源码加载到项目中,按照文档去实现其功能。最后发现有好多bug,比如定位不准,无法拖动等问题。通过阅读和修改TreeGrid类,这些bug都解决了。接着无意中发现,排序有问题。点击列头排序,发现层级结构变混乱了,这个问题比较严重。因为creat ......

flex 自定义Validator

转载自 http://amberoracle.blog.163.com/blog/static/10598633820097262242474/
第一步:写AS类继承mx.validators.Validator ,并导入mx.validators.ValidationResult.
 value中存放需要验证的内容
results数组中存放验证后的结果,如果通过验证,数据为空;如果验证失败,数组中是ValidationResult.对象,内含失败 ......

Flex之TabNavigator

TabNavigator默认是只初始化第一个TAB的,设一下属性,设了后会初始化其他TAB,creationPolicy="all"
补充下tab里面的容器是Canvas
动态生成TabNavigator tab页面
var canvas: Canvas = new Canvas();
canvas.label = "new Tab";
tabNavigator.addChild(canvas);
-------------------------------------------------- ......

flex实例效果图

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="top" applicationComplete="init()">
<mx:Script>
 <![CDATA[
  
  import mx.events.ItemClickEvent;
import mx.collections.ArrayCollection ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号