AS3. Animation Lib Demo (work with Sliding Text)

 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
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.geom.Point;
// Demonstrates the use of the Animator class
public class AnimationLibDemo extends Sprite {
private var circleAnimator:Animator;
public function AnimationLibDemo () {
// Create a message that animates to position (300, 0) over
// the course of one second (1000 ms)
var welcome:SlidingText = new SlidingText(300, 0, 1000);
welcome.text = "Welcome!";
welcome.autoSize = TextFieldAutoSize.LEFT;
addChild(welcome);
// Create a circle to animate
var circle:Shape = new Shape();
circle.graphics.lineStyle(10, 0x666666);
circle.graphics.beginFill(0x999999);
circle.graphics.drawCircle(0, 0, 25);
addChild(circle);
// Create an Animator to animate the circle
circleAnimator = new Animator(circle);
// Register for mouse clicks
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
}
// When the user clicks the stage, animate the
// circle to the point that was clicked.
private function mouseDownListener (e:MouseEvent):void {
var mousePt:Point = globalToLocal(new Point(e.stageX, e.stageY));
circleAnimator.animateTo(mousePt.x, mousePt.y, 500);
}
}
}