返回函数的函数

很好玩的写法,也是很容易让你的团队伙伴崩溃的写法。复制到你的Flash里试试。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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);

来自:Actinsnippet

Comments:
  1. Y.Boy Says:

    真有趣。

  2. logos Says:

    看着就晕…

  3. ohkei Says:

    挺好!~:)

Leave a comment


Verify Code   If you cannot see the CheckCode image,please refresh the page again!