-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTrail.as
69 lines (55 loc) · 1.78 KB
/
Trail.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
57
58
59
60
61
62
63
64
65
66
67
68
69
package
{
import flash.display.*;
import flash.events.*;
import flash.ui.*;
public class Trail extends Sprite
{
private var delay_length:int;
public var trail_length:int;
private var size:int;
private var delay_counter:int;
private var current_end_circle:int;
public var circles:Array;
public function Trail(x:Number,y:Number)
{
delay_length = 6;
trail_length = 12;
size = 3;
current_end_circle = 0;
circles = new Array(trail_length);
circles[0] = new Circle(x,y,size,1);
addChild(circles[0]);
delay_counter = delay_length;
}
public function update(x:Number,y:Number) : void
{
delay_counter = delay_counter-1;
if(delay_counter<0)
{
var last_x:Number = circles[current_end_circle].x
var lasy_y:Number = circles[current_end_circle].y
move_trail(x,y);
if(current_end_circle<(trail_length-1))
{
current_end_circle = current_end_circle+1;
var alpha:Number = 0.5-current_end_circle/(2*trail_length);
circles[current_end_circle] = new Circle(last_x,last_x,size,alpha);
addChild(circles[current_end_circle]);
}
}
}
public function move_trail(x:Number,y:Number): void
{
var i:int = current_end_circle
while(i>0)
{
circles[i].x = circles[i-1].x
circles[i].y = circles[i-1].y
i = i -1;
}
circles[0].x = x;
circles[0].y = y;
}
}
}