This is a *very* cool new feature in ActionScript 3. We now have the ability to dynamically change the SWF frame rate at runtime using ActionScript. In the example below I have a somewhat creepy clown who is animating from side-to-side on the screen. You can use the slider to change the frame rate from 0 to 800 and something. There are a lot of applications for this such as lowering the frame rate for slower machines dynamically. The AS 3 code from the example is posted below:
- this.stage.frameRate = 0;
- rate.text = “0 fps”;
- thumb.addEventListener(MouseEvent.MOUSE_DOWN, starter);
- thumb.addEventListener(MouseEvent.MOUSE_UP, stopper);
- thumb.addEventListener(MouseEvent.MOUSE_OUT, stopper);
- thumb.addEventListener(MouseEvent.MOUSE_MOVE, mover);
- function starter(args:Event)
- {
- thumb.startDrag(false, new Rectangle(track.x, thumb.y, track.width, 0));
- }
- function stopper(args:Event)
- {
- thumb.stopDrag();
- }
- function mover(args:Event)
- {
- var dist:Number = (thumb.x – track.x) / (track.width + track.x);
- this.stage.frameRate = Math.round(dist*1000);
- rate.text = Math.round(dist*1000).toString() + ” fps”;
- }
No comments:
Post a Comment