Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Security.allowDomain("*");
- //imports
- import flash.net.URLRequest;
- import flash.display.Loader;
- import flash.events.Event;
- import flash.events.ProgressEvent;
- import flash.system.LoaderContext;
- import flash.external.ExternalInterface;
- //variable declarations
- var sURL = "http://cdn.aqworlds.com/game/";
- var sFile;
- var versionLoader:URLLoader;
- var game:Object;
- var swfContext:LoaderContext;
- var swfLoader:Loader;
- var swfRequest:URLRequest;
- var percent:Number;
- //function declarations
- function LoadGame()
- {
- swfContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
- swfLoader = new Loader();
- swfRequest = new URLRequest(sURL + "gamefiles/" + sFile);
- swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onGameComplete);
- swfLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onGameProgress);
- swfLoader.load(swfRequest, swfContext);
- stage.quality = StageQuality.LOW;
- percent = 0;
- }
- function onGameComplete(loadEvent:Event)
- {
- stage.addChildAt(loadEvent.currentTarget.content, 0);
- loadEvent.currentTarget.content.y = 0.0;
- loadEvent.currentTarget.content.x = 0.0;
- game = Object(loadEvent.currentTarget.content);
- game.params.sURL = sURL;
- this.gotoAndStop(2);
- }
- function onGameProgress(swfProgress:ProgressEvent)
- {
- percent = Math.round((swfProgress.bytesLoaded/swfProgress.bytesTotal) * 100);
- LoadingBar.width = percent*2
- LoadingText.text = "Loading Game " + percent + "%";
- this.refresh;
- }
- function GetVersion()
- {
- versionLoader = new URLLoader();
- versionLoader.addEventListener(Event.COMPLETE, onVersionComplete);
- versionLoader.load(new URLRequest(sURL + "getversion.asp"));
- }
- function onVersionComplete(param1:Event)
- {
- var vars:URLVariables;
- vars = new URLVariables(param1.target.data);
- if (vars.status == "success")
- {
- sFile = vars.sFile;
- LoadGame();
- }
- else
- {
- this.gotoAndStop(1);
- }
- }
- //Start doing stuff
- GetVersion();
- stop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement