Last active
December 15, 2015 23:22
Revisions
-
steffentchr revised this gist
Dec 15, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ package { var re:RegExp = /\?/; iframeUrl += (re.test(iframeUrl) ? '&' : '?') + parameters.join('&'); } return '<iframe src="'+iframeUrl+'" style="width:'+width+'px; height:'+height+'px;" frameborder="0" border="0" scrolling="no" allowfullscreen="1" mozallowfullscreen="1" webkitallowfullscreen="1"></iframe>'; } public function replaceFlashElement():void { ExternalInterface.call('function(){var iframeNode = document.createElement("div"); iframeNode.innerHTML = \''+getIframeHtml()+'\'; var flashNode = document.getElementById("'+ExternalInterface.objectID+'"); var parentNode = flashNode.parentNode; parentNode.insertBefore(iframeNode, flashNode); parentNode.removeChild(flashNode);}'); -
steffentchr created this gist
Dec 15, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ package { import flash.display.LoaderInfo; import flash.display.Sprite; import flash.external.ExternalInterface; import flash.utils.*; [SWF(width="100%", height="100%")] public class UpgradeToIframe extends Sprite { private var interval:uint; private function getIframeHtml():String { // Get the size of the object var width:int = stage.stageWidth; var height:int = stage.stageHeight; // Parameters var url:String= LoaderInfo(this.root.loaderInfo).loaderURL; var o:Object = LoaderInfo(this.root.loaderInfo).parameters; var parameters:Array = new Array(); var key:String; for (key in o) parameters.push(key + '=' + String(o[key])); // Build URL var iframeUrl:String = url.replace(/.swf/img, '.html'); if(parameters.length>0) { var re:RegExp = /\?/; iframeUrl += (re.test(iframeUrl) ? '&' : '?') + parameters.join('&'); } return '<iframe src="'+iframeUrl+'" style="width:'+width+'px; height:'+height+'px;" frameborder="0" border="0" scrolling="no" allowfullscreen="1" mozallowfullscreen="1" webkitallowfullscreen="1">'; } public function replaceFlashElement():void { ExternalInterface.call('function(){var iframeNode = document.createElement("div"); iframeNode.innerHTML = \''+getIframeHtml()+'\'; var flashNode = document.getElementById("'+ExternalInterface.objectID+'"); var parentNode = flashNode.parentNode; parentNode.insertBefore(iframeNode, flashNode); parentNode.removeChild(flashNode);}'); } public function UpgradeToIframe() { interval = setInterval(function():void { if(ExternalInterface.available) { // Stop timer if(interval) clearInterval(interval); // Replace Flash with iframe replaceFlashElement() } }, 2000); } } }