flex event实例
EventArgExtend.as
package myeventhelper
{
public class EventArgExtend
{
public function EventArgExtend()
{
}
public static function create(f:Function,...arg):Function //addEventListener注册事件进行传递参数的方法
{ //EventArgExtend.create(comB.onGetParentTotal,this)
var F:Boolean = false; //让参数进行并且只一次合并
var _f:Function = function(e:*,..._arg)
{
_arg = arg;
if(!F)
{
F = true;
_arg.unshift(e); //向数组的开始部位加入
}
f.apply(null,_arg); //把参数都放到一个数组里,再传进去;
}
return _f;
}
public static function toString():String
{
return "Class JEventDelegate";
}
}
}
MyEventDispatcher.as 自定义事件发送者类
package myeventhelper
{
import flash.events.EventDispatcher;
import mx.core.UIComponent;
//自定义事件触发类
public class MyEventDispatcher extends EventDispatcher
{
private static var _instance:MyEventDispatcher;
public static const EXEC_PARENT_METHOD:String="ExecParentMethod"; //执行Parent方法
public static function getInstance():MyEventDispatcher
{
if(_instance==null){
_instance=new MyEventDispatcher();
}
return _instance;
}
public var Source:UIComponent; //事件源对象
public var Parsms:Object; //主要用于参数传递
}
}
MyExtendEvent.as 自定义event扩展类
package myeventhelper
{
import mx.events.FlexEvent;
//用户自定义事件类
public class MyExtendEvent extends FlexEvent
{
public static const EXEC_BROTHER_METHOD:String="ExecBrotherMethod";//执行兄弟方法
publ
相关文档:
有好用的东西一定要共享。
PaginationDataGrid.mxml文件分页组件
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
<mx:Script source="../../../common/utils/Commo ......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Style source="skin/yflexskin.css" />
<mx:Script>
<! ......
Flex 4带给我们的,是全新的命名空间。了解这些命名空间必定是一件好事情。Flex 4有三个非常重要的命名空间,分别是:
xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:mx=”library://ns.adobe.com/flex/halo”
xmlns:s=”library://ns.adobe.com/flex/spark&rdq ......
module 接口文件 PictureWindowInterface.as
package
{
public interface PictureWindowInterface
{
function setSelectIndex(index:int):void
}
}
moudule 文件 PictureWindow.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml ......