In ActionScript 3 we are now able to dynamically change the frame rate directly from our actions panel. This gives us the option to change the frame rate at the click of a mouse button or after a certain amount of time. In the example below I've taken the the swf from the Flash Handwriting Tutorial to use as an example. Click the increase and decrease buttons to change the frame rate.
Inside our actions panel we have this code below.
decrease.addEventListener(MouseEvent.CLICK, DecreaseFrame);
function IncreaseFrame(evt:MouseEvent):void {
stage.frameRate += 10;
}
function DecreaseFrame(evt:MouseEvent):void {
stage.frameRate -=10;
}
First we give our IncreaseFrame and DecreaseFrame buttons on the stage some MouseEvents.
decrease.addEventListener(MouseEvent.CLICK, DecreaseFrame);
function IncreaseFrame(evt:MouseEvent):void {
stage.frameRate += 10;
}
function DecreaseFrame(evt:MouseEvent):void {
stage.frameRate -=10;
}
Inside our increase and decrease functions we access the stage property and frameRate properties and tell them to increase by 10 and decrease by 10 each click respectively.
decrease.addEventListener(MouseEvent.CLICK, DecreaseFrame);
function IncreaseFrame(evt:MouseEvent):void {
stage.frameRate += 10;
}
function DecreaseFrame(evt:MouseEvent):void {
stage.frameRate -=10;
}
Of course if you just wanted to change the frame rate from your actions panel with MouseEvents you'd just write;
Simple.
This post is tagged AS3, frameRate, stage
Share This Post
Jobs


























3 Comments
Do you have idea if we can have different frame for a loaded SWF?
Terences last blog post..Flash and Silverlight: 3D Image Rotation
this is fine ………
rajus last blog post..AS3 Guide Colour Tints
Incoming Links
Leave a Reply