forked from Using proxies without crossdomain.xml (diff: 36)
ActionScript3 source code
/**
* Copyright wh0 ( http://wonderfl.net/user/wh0 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zbxF
*/
// forked from wh0's Using proxies without crossdomain.xml
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.utils.*;
public class FlashTest extends Sprite {
// Wrap url in proxy parameter.
private function proxy(url:String):String {
return 'http://www.gmodules.com/ig/proxy?url=' + encodeURIComponent(url);
}
public function FlashTest() {
// Only the top level movie starts off with stage populated.
if (stage) {
// The top level movie is likely included from wonderfl.net and therefore unproxied.
// All we do in this case is load the proxied version.
// Allow the proxy domain so wee can access stage on lines 45-46.
Security.allowDomain('www.gmodules.com');
var l:Loader = new Loader();
l.load(new URLRequest(proxy(loaderInfo.url)));
addChild(l);
return;
} else {
// Allow Wonderfl to take a screen cap.
Security.allowDomain('swf.wonderfl.net');
addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private var tf:TextField;
private var l:Loader;
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// Now you write your own code.
// Since the inner proxied movie is in the proxy's domain, we can request anything.
tf = new TextField();
tf.defaultTextFormat = new TextFormat('MS Gothic', 11);
tf.width = stage.stageWidth;
tf.height = stage.stageHeight;
addChild(tf);
l = new Loader();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, function (e:Event):void {
var mc:MovieClip = l.content as MovieClip;
setTimeout(function ():void {
var clear:Loader = mc.getChildAt(0) as Loader;
stage.addEventListener(MouseEvent.CLICK, function (e:MouseEvent):void {
new FileReference().save(clear.contentLoaderInfo.bytes);
});
trace('click to save');
}, 1000);
});
// redacted
}
private function trace(...args):void {
tf.appendText(args + '\n');
}
}
}