View difference between Paste ID: pt3CZLtr and CDwwQjqh
SHOW: | | - or go back to the newest paste.
1
import flash.events.Event;
2
3
//Comments by Oliboli8769
4-
 
4+
5
Security.allowDomain("*");
6
//URLs as Strings used for easiness
7
var sURL1 = "http://aqworldscdn.aq.com/game/";
8
var sURL2 = "http://cdn.aqworlds.com/game/";
9
var sFile; //used to store game version string
10-
var versionLoader:URLLoader;
10+
var versionLoader: URLLoader;
11-
var Game:Object;
11+
var Game: Object;
12-
var swfContext:LoaderContext;
12+
var swfContext: LoaderContext;
13-
var swfLoader:Loader;
13+
var swfLoader: Loader;
14-
var swfRequest:URLRequest;
14+
var swfRequest: URLRequest;
15
16
GetVersion(); //starts game load
17
18-
function GetVersion()
18+
function GetVersion() {
19-
{
19+
	//checks for most recent game version from ASP file
20-
		//checks for most recent game version from ASP file
20+
	versionLoader = new URLLoader();
21-
        versionLoader = new URLLoader();
21+
	versionLoader.addEventListener(Event.COMPLETE, onVersionComplete); //adds event listener for when the ASP is loaded
22-
        versionLoader.addEventListener(Event.COMPLETE, onVersionComplete); //adds event listener for when the ASP is loaded
22+
	versionLoader.load(new URLRequest(sURL1 + "gameversion.asp")); //same as http://aqworldscdn.aq.com/game/gameversion.asp
23-
        versionLoader.load(new URLRequest(sURL1 + "gameversion.asp")); //same as http://aqworldscdn.aq.com/game/gameversion.asp
23+
24
function onVersionComplete(param1: Event) {
25-
function onVersionComplete(param1:Event)
25+
	//ASP file has now been fully loaded
26-
{
26+
	var vars: URLVariables;
27-
		//ASP file has now been fully loaded
27+
	vars = new URLVariables(param1.target.data); //reads variables held on loaded ASP
28-
        var vars:URLVariables;
28+
	if (vars.status == "success") //checks the 'status' var on ASP
29-
        vars = new URLVariables(param1.target.data); //reads variables held on loaded ASP
29+
	{
30-
        if (vars.status == "success") //checks the 'status' var on ASP
30+
		//after confirmation
31-
        {
31+
		sFile = vars.sFile; //reads game version linkage and saves as the variable sFile
32-
				//after confirmation
32+
		LoadGame(); //now the version is found, we can load the game
33-
                sFile = vars.sFile; //reads game version linkage and saves as the variable sFile
33+
	}
34-
                LoadGame(); //now the version is found, we can load the game
34+
35-
        }
35+
function LoadGame() {
36
	swfContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
37-
function LoadGame()
37+
	swfLoader = new Loader();
38-
{
38+
	swfRequest = new URLRequest(sURL2 + "gamefiles/" + sFile); //using sFile from before as updated game linkage
39-
        swfContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);
39+
	swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onGameComplete); //adds event listener for the game load
40-
        swfLoader = new Loader();
40+
	swfLoader.contentLoaderInfo.addEventListener(flash.events.ProgressEvent.PROGRESS, onGameProgress); //adds event listener for how much the game has loaded
41-
        swfRequest = new URLRequest(sURL2 + "gamefiles/" + sFile); //using sFile from before as updated game linkage
41+
	swfLoader.load(swfRequest, swfContext);
42-
        swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onGameComplete); //adds event listener for the game load
42+
	stage.quality = StageQuality.LOW; //sets stage quality to low, possibly reducing lag (optional)
43-
		swfLoader.contentLoaderInfo.addEventListener(flash.events.ProgressEvent.PROGRESS, onGameProgress); //adds event listener for how much the game has loaded
43+
44-
		swfLoader.load(swfRequest, swfContext);
44+
function onGameComplete(loadEvent: Event) {
45-
        stage.quality = StageQuality.LOW; //sets stage quality to low, possibly reducing lag (optional)
45+
	stage.addChildAt(loadEvent.currentTarget.content, 0); //adds the loaded game content to the stage
46
	loadEvent.currentTarget.content.y = 0.0;
47-
function onGameComplete(loadEvent:Event)
47+
	loadEvent.currentTarget.content.x = 0.0;
48-
{
48+
	Game = Object(loadEvent.currentTarget.content); //stores loaded content onto the Object Game
49-
        stage.addChildAt(loadEvent.currentTarget.content, 0); //adds the loaded game content to the stage
49+
	Game.params.sURL2 = sURL2;
50-
        loadEvent.currentTarget.content.y = 0.0;
50+
	Game.params.sTitle = "Trainer Tutorial By OB";
51-
        loadEvent.currentTarget.content.x = 0.0;
51+
52-
        Game = Object(loadEvent.currentTarget.content); //stores loaded content onto the Object Game
52+
function onGameProgress(arg1: flash.events.ProgressEvent): void {
53-
        Game.params.sURL2 = sURL2;
53+
	//this can be used for progress bars/loaders before trainers
54
	var percentage: *= arg1.bytesLoaded / arg1.bytesTotal;
55-
function onGameProgress(arg1:flash.events.ProgressEvent):void
55+
	trace(percentage * 100); //traces how much the game has loaded as a percentage
56-
        {
56+
	return;
57-
		  //this can be used for progress bars/loaders before trainers
57+
58-
          var percentage:*=arg1.bytesLoaded / arg1.bytesTotal * 100;
58+
function SendPacket(packet: String) {
59-
          trace(loc1); //traces how much the game has loaded as a percentage
59+
	var args: Array = new Array;
60-
		  return;
60+
	var tempArg: String = "";
61-
        }
61+
	var var1: String = "";
62
	var done1: Boolean = false;
63
	var var2: String = "";
64
	var done2: Boolean = false;
65
	var done3: Boolean = false;
66
	var done4: Boolean = false;
67
68
	var i: Number = 1;
69
70
	while (i < packet.length) {
71
		if (packet.charAt(i) != "%") {
72
			if (done1 && !done2) {
73
				var1 += packet.charAt(i);
74
			} else if (done1 && done2 && !done3) {
75
				var2 += packet.charAt(i);
76
			} else if (done1 && done2 && done3 && done4) {
77
				tempArg += packet.charAt(i);
78
			}
79
		} else {
80
			if (!done1) {
81
				done1 = true;
82
			} else if (done1 && !done2) {
83
				done2 = true;
84
			} else if (done1 && done2 && !done3) {
85
				done3 = true;
86
			} else if (done1 && done2 && done3 && !done4) {
87
				done4 = true;
88
			} else if (done1 && done2 && done3 && done4) {
89
				args.push(tempArg);
90
				tempArg = "";
91
			}
92
		}
93
94
		i++;
95
	}
96
97
	var room: String = Game.world.curRoom;
98
99
	switch (var2) {
100
		case "afk":
101
			room = "1";
102
			break;
103
		case "hi":
104
			room = "1";
105
			break;
106
		case "gar":
107
			room = "1";
108
			break;
109
		case "cmd":
110
			room = "1";
111
			break;
112
	}
113
114
	trace("Zone Master: " + var1);
115
	trace("Packet Type: " + var2);
116
	trace("Arguements: " + args);
117
	Game.world.rootClass.sfc.sendXtMessage(var1, var2, args, "str", room);
118
}
119
stop();