`
yaoba
  • 浏览: 41813 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

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

    博客分类:
  • EXT
阅读更多
    今天使用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




  • 描述: 传张照片
  • 大小: 98.2 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics