uxflash.js.svn-base

来自「一个使用ssh+ext的例子。 希望对开发这个应用的人带来好处。仔细研究里面的」· SVN-BASE 代码 · 共 368 行 · 第 1/2 页

SVN-BASE
368
字号
            }

            mc.mediaType = "SWF";
            this.mediaCfg = mc;
            ux.Flash.superclass.initMedia.call(this);

        }

        ,onAfterMedia : function(){

              ux.Flash.superclass.onAfterMedia.apply(this,arguments);
              if(this.SWFObject = this.getInterface()){
                   this.mediaObject.owner = this; //eventSynch binding
              }
         }

        /*
        * Asserts the desired version against the installed Flash Object version.
        * Acceptable parameter formats for versionMap:
        *
        *  '9.0.40' (string)
        *   9  or 9.1  (number)
        *   [9,0,43]  (array)
        *
        *  Returns true if the desired version is => installed version
        *  and false for all other conditions
        */
        ,assertVersion : function(versionMap){

            var compare;
            versionMap || (versionMap = []);

            if(Ext.isArray(versionMap)){
                compare = versionMap;
            } else {
                compare = String(versionMap).split('.');
            }
            compare = (compare.concat([0,0,0,0])).slice(0,3); //normalize

            var tpv;
            if(!(tpv = this.playerVersion || (this.playerVersion = this.detectVersion()) )){ return false; }

            if (tpv.major > parseFloat(compare[0])) {
                        return true;
            } else if (tpv.major == parseFloat(compare[0])) {
                   if (tpv.minor > parseFloat(compare[1]))
                            return true;
                   else if (tpv.minor == parseFloat(compare[1])) {
                        if (tpv.rev >= parseFloat(compare[2]))
                            return true;
                        }
                   }
            return false;
        },
        /*
        * Flash version detection function
        * Modifed version of the detection strategy of SWFObject library : http://blog.deconcept.com/swfobject/
        * returns a {major,minor,rev} version object or
        * false if Flash is not installed or detection failed.
        */
        detectVersion : function(){
            if(this.mediaVersion){
                return this.mediaVersion;
            }
            var version=false;
            var formatVersion = function(version){
              return version && !!version.length?
                {major:version[0] != null? parseInt(version[0],10): 0
                ,minor:version[1] != null? parseInt(version[1],10): 0
                ,rev  :version[2] != null? parseInt(version[2],10): 0
                ,toString : function(){return this.major+'.'+this.minor+'.'+this.rev;}
                }:false;
            };

            if(Ext.isIE){
                var sfo= null;
                try{
                    sfo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
                }catch(e){
                    try {
                        sfo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                        version = [6,0,21];
                        // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this solution)
                        sfo.allowscriptaccess = "always";
                    } catch(e) {
                        if(version && version[0] == 6)
                            {return formatVersion(version); }
                        }
                    try {
                        sfo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                    } catch(e) {}
                }
                if (sfo) {
                    version = sfo.GetVariable("$version").split(" ")[1].split(",");
                }
             }else if(navigator.plugins && navigator.mimeTypes.length){
                var sfo = navigator.plugins["Shockwave Flash"];
                if(sfo && sfo.description) {
                    version = sfo.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".");
                }
            }
            return this.mediaVersion = formatVersion(version);

        }
        //Private
        ,_applyFixes : function() {

             // Fix streaming media troubles for IE
            if(Ext.isIE && this.mediaObject){
                this.mediaVersion || (this.detectVersion());
                // only cleanup if the Flash Player version supports External Interface on IE
                if(this.mediaVersion && this.mediaVersion.major > 7 ){
                        var o = this.mediaObject.dom;
                        o.style.display = 'none';
                        for (var x in o) {
                            if (typeof o[x] == 'function') {
                                o[x] = Ext.emptyFn;
                            }
                        }

                }
            }

        },
        //Remove (safely) an existing mediaObject from the Panels body.
        clearMedia  : function(){

           this._applyFixes();
           ux.Flash.superclass.clearMedia.call(this);
           this.SWFObject = null;
        },

        getSWFObject : function() {
            return this.getInterface();
        },
        /**
         * Dispatches events received from the SWF object.
         *
         * @method _handleEvent
         * @private
         */
        _handleSWFEvent: function(SWF, event)
        {
            var type = event.type||event||false;
            if(type){
                 return this.fireEvent(type, this, SWF, event);
            }
        }

    });
    // Class Method to handle defined Flash interface events
    ux.Flash.eventSynch = function(elementID, event){
            var SWF = Ext.get(elementID);
            if(SWF && SWF.owner){
                return SWF.owner._handleSWFEvent.call(SWF.owner, SWF.dom, event);
            }
        };

    /* Generic Flash BoxComponent */
   Ext.ux.FlashComponent = Ext.extend(Ext.ux.MediaComponent,{
           ctype : "Ext.ux.FlashComponent",
           getId : function(){
                 return this.id || (this.id = "flash-comp" + (++Ext.Component.AUTO_ID));
           }

   });

   //Inherit the Media.Flash class interface
   Ext.apply(Ext.ux.FlashComponent.prototype, ux.Flash.prototype);
   Ext.reg('uxflash', Ext.ux.FlashComponent);

   ux.Panel.Flash = Ext.extend(ux.Panel,{
          ctype : "Ext.ux.Media.Panel.Flash"
   });

   Ext.apply(ux.Panel.Flash.prototype, ux.Flash.prototype);

   Ext.reg('flashpanel', Ext.ux.MediaPanel.Flash = Ext.ux.FlashPanel = ux.Panel.Flash);
   Ext.reg('uxflashpanel', ux.Panel.Flash);

   Ext.ux.FlashWindow = ux.Window.Flash = Ext.extend(ux.Window, {ctype : "Ext.ux.FlashWindow"});
   Ext.apply(ux.Window.Flash.prototype, ux.Flash.prototype);

})();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?