Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.events.Event;
- //Comments by Oliboli8769
- //CHANGES FOR THE LOADING BAR ARE IN CAPS
- Security.allowDomain("*");
- //URLs as Strings used for easiness
- var sURL1 = "http://aqworldscdn.aq.com/game/";
- var sURL2 = "http://cdn.aqworlds.com/game/";
- var sFile; //used to store game version string
- var versionLoader:URLLoader;
- var Game:Object;
- var swfContext:LoaderContext;
- var swfLoader:Loader;
- var swfRequest:URLRequest;
- GetVersion(); //starts game load
- function GetVersion()
- {
- //checks for most recent game version from ASP file
- versionLoader = new URLLoader();
- versionLoader.addEventListener(Event.COMPLETE, onVersionComplete); //adds event listener for when the ASP is loaded
- versionLoader.load(new URLRequest(sURL1 + "gameversion.asp")); //same as http://aqworldscdn.aq.com/game/gameversion.asp
- }
- function onVersionComplete(param1:Event)
- {
- //ASP file has now been fully loaded
- var vars:URLVariables;
- vars = new URLVariables(param1.target.data); //reads variables held on loaded ASP
- if (vars.status == "success") //checks the 'status' var on ASP
- {
- //after confirmation
- sFile = vars.sFile; //reads game version linkage and saves as the variable sFile
- LoadGame(); //now the version is found, we can load the game
- }
- }
- function LoadGame()
- {
- swfContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);
- swfLoader = new Loader();
- swfRequest = new URLRequest(sURL2 + "gamefiles/" + sFile); //using sFile from before as updated game linkage
- swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onGameComplete); //adds event listener for the game load
- swfLoader.contentLoaderInfo.addEventListener(flash.events.ProgressEvent.PROGRESS, onGameProgress); //adds event listener for how much the game has loaded
- swfLoader.load(swfRequest, swfContext);
- stage.quality = StageQuality.LOW; //sets stage quality to low, possibly reducing lag (optional)
- }
- function onGameComplete(loadEvent:Event)
- {
- stage.addChildAt(loadEvent.currentTarget.content, 0); //adds the loaded game content to the stage
- loadEvent.currentTarget.content.y = 0.0;
- loadEvent.currentTarget.content.x = 0.0;
- Game = Object(loadEvent.currentTarget.content); //stores loaded content onto the Object Game
- Game.params.sURL2 = sURL2;
- //WHEN THE LOAD IS COMPLETE, HIDE THE LOADING BAR
- loadingBar.visible = false;
- }
- function onGameProgress(arg1:flash.events.ProgressEvent):void
- {
- //this can be used for progress bars/loaders before trainers
- //CHANGES THE X SCALE OF THE LOADING BAR BY
- var percentage:*=arg1.bytesLoaded / arg1.bytesTotal;
- trace(loc1 * 100); //traces how much the game has loaded as a percentage
- loadingBar.scaleX = percentage; //WHERE THE SCALE CHANGE TAKES PLACE
- return;
- }
- stop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement