Advertisement
Guest User

Untitled

a guest
May 27th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Step 1: In order to load remote content from one domain into a SWF playing on another domain, you need to have
  2. // a file named "crossdomain.xml" located in the root of the remote server. So, for instance, if you are loading
  3. // your game from "http://mydomain.com/games/adventuregame/my_adventure_game.swf", you need to have a crossdomain file
  4. // located at "http://mydomain.com/crossdomain.xml"
  5. //
  6. // The crossdomain file should look like this: http://fekrack.net/crossdomain.xml
  7. // (You can just copy/paste that file onto your server, if you want)
  8.  
  9.  
  10. // Step 2: This allows your game SWF to access the stage, as well as other global variables
  11. try {
  12.     Security.allowDomain("*");
  13.     Security.allowInsecureDomain("*");
  14. } catch(err){
  15. }
  16.  
  17. // Step 3: Figure out where the game is being hosted
  18. var url:String=this.loaderInfo.url;
  19. var domain:String="";
  20. if(url) {
  21.     var urlParts:Array = url.split("/");
  22.     if(urlParts.length>=3) {
  23.         url = urlParts[2];
  24.         urlParts = url.split(".");
  25.         domain = urlParts[urlParts.length-2]+"."+urlParts[urlParts.length-1];
  26.     } else {
  27.         domain = "";
  28.     }
  29. }
  30. if(String(domain)=="undefined.") domain="offline";
  31. trace("The game is being hosted at: '"+String(domain)+"'.");
  32.  
  33. if(domain.indexOf("http://d.facdn.net")!=-1) {
  34.     // DO SOMETHING IF THE GAME IS BEING HOSTED ON FURAFFINITY
  35. }
  36.  
  37. // Step 4: Load your game
  38. var gameLoader:Loader = new Loader();
  39. gameLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
  40. gameLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
  41. gameLoader.load(new URLRequest("http://fekrack.net/toy_tester/toytester.swf"));
  42. addChild(gameLoader);
  43.  
  44. function errorHandler(event:ErrorEvent):void {
  45.     trace("An error occurred while loading your game: "+event);
  46. }
  47.  
  48. stop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement