Created
August 8, 2012 16:03
-
-
Save mizchi/3296219 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _Main { | |
static function main(args : string[]) :void { | |
log "Hello, world!"; | |
var p1:Point = new Point(10,20); | |
var p2:Point = new Point(30,10); | |
log p1.distance(p2); | |
} | |
} | |
class Point { | |
var x: int; | |
var y: int; | |
function constructor(x:int, y:int) { | |
this.x = x; | |
this.y = y; | |
} | |
function distance(other:Point):number { | |
var square: (int) -> int = (x:int) -> Math.pow(x,2); | |
var n:int = square(this.x - other.x) + square(this.y - other.y); | |
return Math.sqrt(n); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment