Simple movement

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package {
import flash.display.*;
import flash.events.*;
 
public class AnimationTest extends MovieClip {
 
public function AnimationTest() {
stage.addEventListener(MouseEvent.CLICK,redrawCursor);
}
 
public function getRandomSpeed() {
var speed:Number = Math.random()*70+30;
if (Math.random() > .5) speed *= -1;
return speed;
}
 
public function redrawCursor(event:MouseEvent):void{
for(var i:uint=0;i<20;i++) {
var a:AnimatedObject = new AnimatedObject(event.stageX,event.stageY,getRandomSpeed(),getRandomSpeed(),3);
addChild(a);
}
}
}
}

Класс .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
70
71
72
73
74
75
76
77
78
79
80
81
package {
import flash.display.*;
import flash.events.*;
import flash.utils.getTimer;
 
public class extends MovieClip {
private var , :Number;
private var lastTime:int;
 
public function (x,y) {
switch() {
case 1 :
this.x = x;
this.y = y;
= dx;
= dy;
lastTime = getTimer();


addEventListener(Event.ENTER_FRAME);
break;
case 2 :
this.x = x;
this.y = y;
= dx;
= dy;
lastTime = getTimer();


addEventListener(Event.ENTER_FRAME, );
break;
case 3 :
this.x = x;
this.y = y;
= dx;
= dy;
lastTime = getTimer();
addEventListener(Event.ENTER_FRAME);
break;
}
}
 
 
public function (event:Event) {
var timePassed:int = getTimer() - lastTime;
lastTime += TimePassed;
 
this.x += *timePassed/1000;
this.y += *timePassed/1000;
}
 
public function (event:Event) {
var timePassed:int = getTimer() - lastTime;
lastTime += TimePassed;
 
this.x += *timePassed/1000;
this.y += *timePassed/1000;
if(this.y<0 || this.y>378) {
this.removeEventListener(Event.ENTER_FRAME, );
}
if(this.x<0 || this.x>527) {
this.removeEventListener(Event.ENTER_FRAME, );
}
}
 
public function (event:Event) {
var timePassed:int = getTimer() - lastTime;
lastTime += TimePassed;
this.x += *timePassed/1000;
this.y += *timePassed/1000;
if(this.y<0 || this.y>378) {
*=-1;
}
if(this.x<0 || this.x>527) {
*=-1;
}
}
 
}
}
 

Nice Ajax Poll

Which one of my extensions is the best?

Statistics

Advertisement