I originally wanted to release the source after my vacation was over but because of Riigged's release I am giving out the full source to my client now. You can find it in my ****** SometimesRain/crazyclient. All contributions are welcome.
Setup tutorial
Download and install FlashDevelop. It will ask which SDKs you would like to install at some point of the installation or when first time opening the program. You'll only need Flex SDK.
When the program is open choose "Open an existing project" on the project window. Choose WebMain.as3proj. Now you need to choose Project menu option on the top row and make sure the platform is Flash Player 11.2.
If you want to debug the project get a debug projector and go to Tools -> Program Settings -> Plugins -> FlashViewer and set the external player path to the debug projector. Now when you want to debug you select "Debug" on the dropdown menu and press the green run button. When you want a release build, it's better to press the cog and run the client from your bin folder. This way the slower debug projector will only be used for debugging.
When debugging the projector will attach to the IDE. If the projector crashes, the IDE will show you the function that failed. You can view all variable values by hovering your mouse over them. I'm hoping someone finds a fix to that never loading to nexus bug.
Important classes
HUDView.as - HUD elements
Player.as - Player code
Projectile.as - Projectiles and status effects
Parameters.as - Default hotkeys (They need to be set)
MapUserInput.as - Custom hotkeys
Options.as - Custom options
GameServerConnectionConcrete.as - Packet related stuff
TextHandler.as - Chat triggered functionality
ParseChatMessageCommand.as - Custom commands
ActionScript oddities
var obj:Object = param1 || new Object();
Sets obj to param1 if param1 != null else creates a new Object.
boolean && doSomething();
Calls the function if boolean is true. Decompiler language.
Use vectors instead of arrays
var vect:Vector.<int> = new <int>[1,2,3];
Clearing a vector
vect.length = 0;
I am not joking. This is the best way to clear a vector. Applies to arrays as well.
No block scope
Code:
if (bool) {
var str:String = "Enabled";
}
trace(str); //prints the value, undefined if bool = false
A good practice is to define variables in the beginning of a function and reuse them when possible
Integers are booleans (0 = false, other values = true)
Code:
var i:int = 0;
if (i) {
trace("not called");
}
No function overloading (this causes compiler error)
Code:
private function add(a:Number, b:Number):Number {
return a+b;
}
private function add(a:String, b:String):int {
return parseInt(a)+parseInt(b);
}
Dictionaries are a total nightmare, try to avoid them. Looping through them causes trouble and they don't even have a length/size field.
IDE tips
If you need an import, start declaring a variable. If you want to import com.company.assembleegameclient.objects.Player you could write the following:
var p:Play
Now you're given a list of options to import. Select the correct one and remove the line you just wrote if it's unnecessary.
If you ever need to find a specific piece of code it's better to use a grepping software such as AstroGrep to go through the source.