-
Notifications
You must be signed in to change notification settings - Fork 0
/
FramRateController.as
48 lines (37 loc) · 1 KB
/
FramRateController.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
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class FramRateController extends MovieClip {
public function FramRateController() {
// constructor code
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
public function onAddedToStage(event:Event)
{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
faster.addEventListener(MouseEvent.CLICK, onFaster);
slower.addEventListener(MouseEvent.CLICK, onSlower);
}
public function onRemovedFromStage(event:Event)
{
removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
faster.removeEventListener(MouseEvent.CLICK, onFaster);
slower.removeEventListener(MouseEvent.CLICK, onSlower);
}
public function onFaster(e:MouseEvent)
{
if (stage.frameRate < 60)
{
stage.frameRate += 5;
}
}
public function onSlower(e:MouseEvent)
{
if (stage.frameRate > 30)
{
stage.frameRate -= 5;
}
}
}
}