您的位置:首页 > Web前端 > JavaScript

使用FABridge,在ActionScript和javaScript之间进行事件传递

2011-02-18 17:05 507 查看
FABridge的使用参考

官方文档

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf61f3a-7fff.html

http://help.adobe.com/en_US/flashbuilder/using/WS6f97d7caa66ef6eb1e63e3d11b6c4d0d21-7e0e.html

中文

http://www.cnblogs.com/dongli/archive/2010/01/25/1655884.html

html接收Flex事件

在html页面中注册事件监听

1. 在html页面onload中进行事件监听注册

// "flash"是FABridge的名称
this.parent.FABridge.addInitializationCallback("flash", function()
{
// 获取Flash对象 flash为FABridge的名称
var flexApp = FABridge.flash.root();

// Register event handler(s) DirectionEvent为自定义事件
flexApp.addEventListener("DirectionEvent", function(event) {
// event事件的属性toValue使用getToValue()获取, fromValue相同
getDirection(event.getToValue(), event.getFromValue())

});
});


JavaScript事件处理

function getDirection(to, from)
{

alert("Html page recieved data:"+to+", "+from);

}


2. Flex中定义DirectionEvent

package
{
import flash.events.Event;

public class DirectionEvent extends Event
{
public static const EVENT_DIRECTION:String = "DirectionEvent"

public var toValue:String= null;
public var fromValue:String= null;

public function DirectionEvent(toValue:String, fromValue:String):void
{
super(EVENT_DIRECTION, true);

this.toValue = toValue;
this.fromValue = fromValue;
}
}
}


3. Flex中下发事件

var ev:DirectionEvent = new DirectionEvent(toId.text, fromId.text);
this.dispatchEvent(ev);


示例 : Flex-IFrame的 IFrameCommTest例子

http://code.google.com/p/flex-iframe/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐