| This is NOT the official website of AvantBiz Consulting Limitd but just some casual discussions about various topics. Please visit www.avantbiz.com if you need our professional services. |
ActionScript 3 QuickTip #1: Dynamic Frame Rates December 14, 2006
Posted by eddie in : Computer 電腦,Flash , trackbackActionScript 3 QuickTip #1: Dynamic Frame Rates
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”;
-
}
Comments»
no comments yet - be the first?