-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo_intersection.as
56 lines (52 loc) · 1.9 KB
/
demo_intersection.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package {
import amitp.Debug;
import flash.display.*;
import flash.geom.*;
[SWF(width="300",height="300")]
public class demo_intersection extends Sprite {
public var intersection:Intersection = new Intersection();
public function demo_intersection() {
intersection.x = 150;
intersection.y = 150;
addChild(intersection);
for (var i:int = 0; i < intersection.approaches.length; i++) {
var drLeft:Draggable = new Draggable
(Model.ref(intersection.approaches[i], 'inLanes')
.callback(intersection.redraw)
.rounded()
.clamped(0, 4)
.multiply(10)
.project(V.left(intersection.dir[i]))
.offset(new Point(intersection.dir[i].x * 50,
intersection.dir[i].y * 50)));
var drRight:Draggable = new Draggable
(Model.ref(intersection.approaches[i], 'outLanes')
.callback(intersection.redraw)
.rounded()
.clamped(0, 4)
.multiply(10)
.project(V.right(intersection.dir[i]))
.offset(new Point(intersection.dir[i].x * 70,
intersection.dir[i].y * 70)));
for each (var config:* in
[ {s: drLeft.normalShape, c: 0x0000dd},
{s: drLeft.hoverShape, c: 0x0000dd},
{s: drLeft.draggingShape, c: 0x0000ff},
{s: drRight.normalShape, c: 0x00dd00},
{s: drRight.hoverShape, c: 0x00dd00},
{s: drRight.draggingShape, c: 0x00ff00},
]) {
var color:int = config.c;
with (config.s.graphics) {
clear();
beginFill(color);
drawRect(-3, -3, 7, 7);
endFill();
}
}
intersection.addChild(drLeft);
intersection.addChild(drRight);
}
}
}
}