Functions Returning Functions (Revised)
Functions Returning Functions (Revised)
original: http://actionsnippet.com/?p=2430
- Removed line variable by using arguments.callee.
/**
* Copyright nitoyon ( http://wonderfl.net/user/nitoyon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6Cms
*/
// Functions Returning Functions (Revised)
// original: http://actionsnippet.com/?p=2430
// - Removed line variable by using arguments.callee.
package {
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
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;
};
}
// 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);
}
}
}