Skip to content

Instantly share code, notes, and snippets.

View devboy's full-sized avatar

Dominic Graefen devboy

View GitHub Profile
@devboy
devboy / MyProject.as
Created November 2, 2011 12:52
Use robotlegs2 and swiftsuspenders2 snapshot builds with buildr-as3
//put this class in src/main/as3
package
{
import flash.display.Sprite;
import org.robotlegs.v2.core.impl.Context;
import org.swiftsuspenders.ReflectorBase;
[SWF(width="1024",height="768")]
public class MyProject extends Sprite
{
@devboy
devboy / BlueForestDev.xml
Created November 2, 2011 18:21
BlueForest for IDEA11
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="BlueForestDev" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Menlo" />
<colors>
<option name="ADDED_LINES_COLOR" value="8080" />
<option name="ANNOTATIONS_COLOR" value="8080ff" />
<option name="ANNOTATIONS_MERGED_COLOR" value="80ff80" />
<option name="CARET_COLOR" value="ffffff" />
@devboy
devboy / Test.as
Created November 4, 2011 12:03
Mixins with include in AS3
// ActAsDog.as
public function bark(): void
{
trace("bark");
}
// ActAsCat.as
public function meow(): void
haxelib install nodejs 0.6
@devboy
devboy / avoidDynamic
Created November 19, 2011 17:41
Avoiding Dynamic types in haXe
static inline function array_delete_if<T>( array: Array<T>, processor: T -> Bool ):Array<T>
{
for ( item in array )
if ( processor(item) )
array.remove( item );
return array;
}
@devboy
devboy / typeInf.as
Created November 21, 2011 23:38
type inference basics
var x; // type of x is Unknown
x = "I'm a String"; // type of x is set to String
x = 1; // this will cause a compiler error as Int cannot be assigned to String
var x: String; // type is now set to String
x = "I'm a String"; // this will work
x = 1; // this will cause an error
function inferred(x) {
return x;
}
inferred("abc"); // will take the string and return it
inferred(1); // will throw a compiler error because x is typed to String now
function square( x: Float ) {
return x * x;
}
var square = function(x: Float) {
return x * x;
}
type(square); // type of square is Float -> Float