as\flex 中添加事件addEventListener()时传递参数
/**
* @author:ycccc8202
* @用途:注册事件进行传递参数的代理类
* @date:2007.8.26
* @example:
* import com.ycccc.utils.JEventDelegate
stage.addEventListener(MouseEvent.MOUSE_DOWN,JEventDelegate.create(mouseDownHandler,"a","b"));
function mouseDownHandler(e:MouseEvent,...arg) {
trace(e)
trace(arg)
}
*/
package com.projectstateview.comm.method
{
import flash.events.Event;
public class JEventDelegate
{
public function JEventDelegate()
{
}
public static function create(f:Function,... arg):Function
{
return function(e:Event):void
{
f.apply(null,[e].concat(arg));
}
}
public static function toString():String
{
return "Class JEventDelegate";
}
}
}
相关文档:
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the DateTimeAxis class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
......
在flex开发环境中编写as3代码是很方便的,借助flex开发环境代码都有自动提示功能,但是在做flash游戏的时候,在涉及到对话框的时候,我遇到一个很棘手的问题,就是在美工用flash cs布局好了的界面,我在界面上命名了实例(如textfield类型 var nameText:String),在导出这个类(guestDialog)的时候(这个类继承自MovieClip ......
flex3 中的中文字体只支持有限的几种,要么嵌入字体,要么就使用这几种:
支持一些默认的英文字体,如Arial、Times New Roman、Courier New、Georgia、Verdana等。
支持的中文字体:宋体、华文楷体、华文细黑、华文仿宋、华文中宋。
Flex3 中即使客户端装了很多字体,能使用的也只能是上面几种字体,除非嵌入字体。
但是 ......
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/04/adding-animations-and-effects-to-flex-tool-tips/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertic ......
Flex应用开发过程中如需要灵活的在不同组件(如A与B,父与子)之间响应事件,传递参数等功能时就会使用自定义事件(Event)机制,下面通过一个事例分七步,通过自定义Event和EventDispatcher两种机制实现事件交互和参数传递;
事例描述: 有一个父亲“parentApp.mxml&rd ......