使用Ext.FlashComponent创建flex不会触发initialize事件

今天使用Ext.FlashComponent添加一个照像功能的flex发现不会执行initialize事件,找了半天没结果,翻了charts的源码才发现initializeComponent后有个javascript的回调方法


this.initializeComponent();
swfReady;
this.dispatchEventToJavaScript(swfReady);



protected function dispatchEventToJavaScript(param1:Object) : void
{
var event:* = param1;
try
{
if (ExternalInterface.available)
{
ExternalInterface.call(this.javaScriptEventHandler, this.elementID, event);
}
}
catch (error:Error)
{
if (error is SecurityError)
{
this.showFatalError("Warning: Cannot establish communication between YUI Charts and JavaScript. YUI Charts must be served from HTTP and cannot be viewed locally with file:/// protocol unless location is trusted by Flash Player.\n\nFor more information see:\nhttp://www.adobe.com/products/flashplayer/articles/localcontent/\n\n");
}
}
return;
}// end function


问题找到了,现在在自己的flex加个代码

protected function applicationComplete() : void
{

this.elementID = this.loaderInfo.parameters.elementID;
//从参数中得到JS提供给Actionscript的事件回调函数
this.javaScriptEventHandler = this.loaderInfo.parameters.eventHandler;


if (ExternalInterface.available)
{

this.dispatchEventToJavaScript({type:"swfReady"});
}
else
{
throw new IOError("Flash YUIComponent cannot communicate with JavaScript content.");
}
}// end function



[img]http://dl.iteye.com/upload/attachment/165095/dfbb939c-d7fa-3579-a4ac-7abb82713809.jpg[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值