var connect:Function = function(xp:Number, yp:Number, col:uint=0):Function{
graphics.lineStyle(0,col);
graphics.moveTo(xp, yp);
var line:Function = function(xp:Number, yp:Number):Function{
graphics.lineTo(xp, yp);
return line;
}
return line;
}
// draw a triangle
connect(200,100)(300,300)(100,300)(200, 100);
// draw a box
connect(100,100, 0xFF0000)(150,100)(150,150)(100, 150)(100,100);
This is one of those techniques that I never really get tired of. It’s pretty useless, but fun to play around with every now and then. This draws the somewhat boring looking picture below:

[EDIT]
A few people pointed out that this could be simplified with arguments.callee… So here is an example… it does the same thing as the original code…
var connect:Function = function(xp:Number, yp:Number, col:uint=0):Function{
graphics.lineStyle(0,col);
graphics.moveTo(xp, yp);
return function(xp:Number, yp:Number):Function{
graphics.lineTo(xp, yp);
return arguments.callee;
}
}
