📄 flash.js
字号:
} }, // Initializes dojo.flash. _initialize: function(){ //dojo.debug("dojo.flash._initialize"); // see if we need to rev or install Flash on this platform var installer = new dojo.flash.Install(); dojo.flash.installer = installer; if(installer.needed() == true){ installer.install(); }else{ //dojo.debug("Writing object out"); // write the flash object into the page dojo.flash.obj = new dojo.flash.Embed(this._visible); dojo.flash.obj.write(dojo.flash.info.commVersion); // initialize the way we do Flash/JavaScript communication dojo.flash.comm = new dojo.flash.Communicator(); } }};dojo.flash.Info = function(){ // summary: A class that helps us determine whether Flash is available. // description: // A class that helps us determine whether Flash is available, // it's major and minor versions, and what Flash version features should // be used for Flash/JavaScript communication. Parts of this code // are adapted from the automatic Flash plugin detection code autogenerated // by the Macromedia Flash 8 authoring environment. // // An instance of this class can be accessed on dojo.flash.info after // the page is finished loading. // // This constructor must be called before the page is finished loading. // Visual basic helper required to detect Flash Player ActiveX control // version information on Internet Explorer if(dojo.render.html.ie){ document.writeln('<script language="VBScript" type="text/vbscript"\>'); document.writeln('Function VBGetSwfVer(i)'); document.writeln(' on error resume next'); document.writeln(' Dim swControl, swVersion'); document.writeln(' swVersion = 0'); document.writeln(' set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))'); document.writeln(' if (IsObject(swControl)) then'); document.writeln(' swVersion = swControl.GetVariable("$version")'); document.writeln(' end if'); document.writeln(' VBGetSwfVer = swVersion'); document.writeln('End Function'); document.writeln('</script\>'); } this._detectVersion(); this._detectCommunicationVersion();}dojo.flash.Info.prototype = { // version: String // The full version string, such as "8r22". version: -1, // versionMajor, versionMinor, versionRevision: String // The major, minor, and revisions of the plugin. For example, if the // plugin is 8r22, then the major version is 8, the minor version is 0, // and the revision is 22. versionMajor: -1, versionMinor: -1, versionRevision: -1, // capable: Boolean // Whether this platform has Flash already installed. capable: false, // commVersion: int // The major version number for how our Flash and JavaScript communicate. // This can currently be the following values: // 6 - We use a combination of the Flash plugin methods, such as SetVariable // and TCallLabel, along with fscommands, to do communication. // 8 - We use the ExternalInterface API. // -1 - For some reason neither method is supported, and no communication // is possible. commVersion: 6, // installing: Boolean // Set if we are in the middle of a Flash installation session. installing: false, isVersionOrAbove: function( /* int */ reqMajorVer, /* int */ reqMinorVer, /* int */ reqVer){ /* Boolean */ // summary: // Asserts that this environment has the given major, minor, and revision // numbers for the Flash player. // description: // Asserts that this environment has the given major, minor, and revision // numbers for the Flash player. // // Example- To test for Flash Player 7r14: // // dojo.flash.info.isVersionOrAbove(7, 0, 14) // returns: // Returns true if the player is equal // or above the given version, false otherwise. // make the revision a decimal (i.e. transform revision 14 into // 0.14 reqVer = parseFloat("." + reqVer); if(this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer && this.versionRevision >= reqVer){ return true; }else{ return false; } }, _detectVersion: function(){ var versionStr; // loop backwards through the versions until we find the newest version for(var testVersion = 25; testVersion > 0; testVersion--){ if(dojo.render.html.ie){ versionStr = VBGetSwfVer(testVersion); }else{ versionStr = this._JSFlashInfo(testVersion); } if(versionStr == -1 ){ this.capable = false; return; }else if(versionStr != 0){ var versionArray; if(dojo.render.html.ie){ var tempArray = versionStr.split(" "); var tempString = tempArray[1]; versionArray = tempString.split(","); }else{ versionArray = versionStr.split("."); } this.versionMajor = versionArray[0]; this.versionMinor = versionArray[1]; this.versionRevision = versionArray[2]; // 7.0r24 == 7.24 var versionString = this.versionMajor + "." + this.versionRevision; this.version = parseFloat(versionString); this.capable = true; break; } } }, // JavaScript helper required to detect Flash Player PlugIn version // information. Internet Explorer uses a corresponding Visual Basic // version to interact with the Flash ActiveX control. _JSFlashInfo: function(testVersion){ // NS/Opera version >= 3 check for Flash plugin in plugin array if(navigator.plugins != null && navigator.plugins.length > 0){ if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]){ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; if(descArray[3] != ""){ var tempArrayMinor = descArray[3].split("r"); }else{ var tempArrayMinor = descArray[4].split("r"); } var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; var version = versionMajor + "." + versionMinor + "." + versionRevision; return version; } } return -1; }, // Detects the mechanisms that should be used for Flash/JavaScript // communication, setting 'commVersion' to either 6 or 8. If the value is // 6, we use Flash Plugin 6+ features, such as GetVariable, TCallLabel, // and fscommand, to do Flash/JavaScript communication; if the value is // 8, we use the ExternalInterface API for communication. _detectCommunicationVersion: function(){ if(this.capable == false){ this.commVersion = null; return; } // detect if the user has over-ridden the default flash version if (typeof djConfig["forceFlashComm"] != "undefined" && typeof djConfig["forceFlashComm"] != null){ this.commVersion = djConfig["forceFlashComm"]; return; } // we prefer Flash 6 features over Flash 8, because they are much faster // and much less buggy // at this point, we don't have a flash file to detect features on, // so we need to instead look at the browser environment we are in if(dojo.render.html.safari == true || dojo.render.html.opera == true){ this.commVersion = 8; }else{ this.commVersion = 6; } }};dojo.flash.Embed = function(visible){ // summary: A class that is used to write out the Flash object into the page. this._visible = visible;}dojo.flash.Embed.prototype = { // width: int // The width of this Flash applet. The default is the minimal width // necessary to show the Flash settings dialog. Current value is // 215 pixels. width: 215, // height: int // The height of this Flash applet. The default is the minimal height // necessary to show the Flash settings dialog. Current value is // 138 pixels. height: 138, // id: String // The id of the Flash object. Current value is 'flashObject'. id: "flashObject", // Controls whether this is a visible Flash applet or not. _visible: true, protocol: function(){ switch(window.location.protocol){ case "https:": return "https"; break; default: return "http"; break; } }, write: function(/* String */ flashVer, /* Boolean? */ doExpressInstall){ // summary: Writes the Flash into the page. // description: // This must be called before the page // is finished loading. // flashVer: String // The Flash version to write. // doExpressInstall: Boolean // Whether to write out Express Install // information. Optional value; defaults to false. //dojo.debug("write"); if(dojo.lang.isUndefined(doExpressInstall)){ doExpressInstall = false; } // determine our container div's styling var containerStyle = new dojo.string.Builder(); containerStyle.append("width: " + this.width + "px; "); containerStyle.append("height: " + this.height + "px; "); if(this._visible == false){ containerStyle.append("position: absolute; "); containerStyle.append("z-index: 10000; "); containerStyle.append("top: -1000px; "); containerStyle.append("left: -1000px; "); } containerStyle = containerStyle.toString(); // figure out the SWF file to get and how to write out the correct HTML // for this Flash version var objectHTML; var swfloc; // Flash 6 if(flashVer == 6){ swfloc = dojo.flash.flash6_version; var dojoPath = djConfig.baseRelativePath; swfloc = swfloc + "?baseRelativePath=" + escape(dojoPath); objectHTML = '<embed id="' + this.id + '" src="' + swfloc + '" ' + ' quality="high" bgcolor="#ffffff" ' + ' width="' + this.width + '" height="' + this.height + '" ' + ' name="' + this.id + '" ' + ' align="middle" allowScriptAccess="sameDomain" ' + ' type="application/x-shockwave-flash" swLiveConnect="true" ' + ' pluginspage="' + this.protocol() + '://www.macromedia.com/go/getflashplayer">'; }else{ // Flash 8 swfloc = dojo.flash.flash8_version; var swflocObject = swfloc; var swflocEmbed = swfloc; var dojoPath = djConfig.baseRelativePath; if(doExpressInstall){ // the location to redirect to after installing var redirectURL = escape(window.location); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; var docTitle = escape(document.title); swflocObject += "?MMredirectURL=" + redirectURL + "&MMplayerType=ActiveX" + "&MMdoctitle=" + docTitle + "&baseRelativePath=" + escape(dojoPath); swflocEmbed += "?MMredirectURL=" + redirectURL + "&MMplayerType=PlugIn" + "&baseRelativePath=" + escape(dojoPath); } if(swflocEmbed.indexOf("?") == -1){ swflocEmbed += "?baseRelativePath="+escape(dojoPath)+"' "; } objectHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' + 'codebase="' + this.protocol() + '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/' + 'swflash.cab#version=8,0,0,0" ' + 'width="' + this.width + '" ' + 'height="' + this.height + '" ' + 'id="' + this.id + '" ' + 'align="middle"> ' + '<param name="allowScriptAccess" value="sameDomain" /> ' + '<param name="movie" value="' + swflocObject + '" /> ' + '<param name="quality" value="high" /> ' + '<param name="bgcolor" value="#ffffff" /> ' + '<embed src="' + swflocEmbed + "' " + 'quality="high" ' + 'bgcolor="#ffffff" ' + 'width="' + this.width + '" ' + 'height="' + this.height + '" ' + 'id="' + this.id + '" ' + 'name="' + this.id + '" ' + 'swLiveConnect="true" ' + 'align="middle" ' + 'allowScriptAccess="sameDomain" ' + 'type="application/x-shockwave-flash" ' + 'pluginspage="' + this.protocol() +'://www.macromedia.com/go/getflashplayer" />' + '</object>'; } // now write everything out objectHTML = '<div id="' + this.id + 'Container" style="' + containerStyle + '"> ' + objectHTML + '</div>'; document.writeln(objectHTML); }, get: function(){ /* Object */ // summary: Gets the Flash object DOM node. //return (dojo.render.html.ie) ? window[this.id] : document[this.id]; // more robust way to get Flash object; version above can break // communication on IE sometimes return document.getElementById(this.id); }, setVisible: function(/* Boolean */ visible){ // summary: Sets the visibility of this Flash object. var container = dojo.byId(this.id + "Container"); if(visible == true){ container.style.visibility = "visible"; }else{ container.style.position = "absolute"; container.style.x = "-1000px"; container.style.y = "-1000px"; container.style.visibility = "hidden"; } }, center: function(){ // summary: Centers the flash applet on the page. var elementWidth = this.width; var elementHeight = this.height; var scroll_offset = dojo.html.getScroll().offset; var viewport_size = dojo.html.getViewport(); // compute the centered position var x = scroll_offset.x + (viewport_size.width - elementWidth) / 2; var y = scroll_offset.y + (viewport_size.height - elementHeight) / 2; // set the centered position var container = dojo.byId(this.id + "Container"); container.style.top = y + "px"; container.style.left = x + "px"; }};dojo.flash.Communicator = function(){ // summary: // A class that is used to communicate between Flash and JavaScript in // a way that can pass large amounts of data back and forth reliably, // very fast, and with synchronous method calls. // description: // A class that is used to communicate between Flash and JavaScript in // a way that can pass large amounts of data back and forth reliably, // very fast, and with synchronous method calls. This class encapsulates the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -