logo
468x60-2-495


  • Home
  • Privacy Policy
  • About
search
top
Jan 20, 2011 Posted on Jan 20, 2011 in Hints and Tips | 0 comments

Quick Tip: Change the Frame Rate at Runtime Using ActionScript 3

Dive into this Quick Tip and discover how to change the Frame Rate of your movie, while it’s running…


Final Result Preview

Let’s take a look at the final result we will be working towards:


Step 1: Brief Overview

We’ll make use of a Slider component to modify the stage framerate property and display a MovieClip to see the changes.


Step 2: Set Up Your Flash File

Launch Flash and create a new Flash Document, set the stage size to 400x200px and the frame rate to 25fps.


Step 3: Interface

This is the interface we’ll be using, it includes a Slider Component and a MovieClip taken from my Apple Preloader tutorial.

You’ll also notice some static text below the slider indicating the minimum and maximum FPS.


Step 4: Slider

Open the Components Panel (Cmd+F7) and drag the Slider component from the User Interface folder, align it to the center in the stage and click the Properties Panel to edit its parameters.

Use the data from the image above and prepare for some ActionScript 3…


Step 5: ActionScript

Create a new ActionScript Class (Cmd+N), save the file as Main.as and start writing:

package
{
	import flash.display.Sprite;
	import fl.events.SliderEvent;

	public class Main extends Sprite
	{
		public function Main():void
		{
			//Listen for slider movement
			slider.addEventListener(SliderEvent.CHANGE, changeFPS);
		}

		private function changeFPS(e:SliderEvent):void
		{
			//Change the frame rate using the slider value
			stage.frameRate = e.value;
		}
	}
}

Step 6: Document Class

Remember to add the class name to the Class field in the Publish section of the Properties panel.


Conclusion

Try the demo and experiment with the uses of this feature!

I hope you liked this Quick Tip, thank you for reading!



View full post on Activetuts+

banner ad

Leave a Reply

Click here to cancel reply.

search search search search search
Find an Article
Categories
  • Flash Video Training
  • Hints and Tips
  • Recommended
Please Support Our Sponsors
Recent Posts
  • Workshop Coding Challenge: Fix This Breakout Game
  • Enable the Latest AIR SDK in Flash Professional CS5.5+
  • Quick Tip: Versioning Your Files With Dropbox (via Webdesigntuts+)
  • Workshop: Nuclear Outrun – Critique
  • Understanding Variables, Arrays, Loops, and Null: The Post-it Note Analogy
Tag Cloud
2011 ActionScript Active Activetuts+ Adobe animation Basic Basix Best Build Button Character Create Creating Critique Custom design Effect Effects Files Flash from Game Guide HTML5 Introduction Macromedia Motion Muzzle part Player Premium Professional Quick Silverlight Simple Text Tool Tutorial Tuts+ Tween Using Video website Workshop
About Our Site:

Hey there and welcome to "Flash Video Training Source", a resource for anybody interested in learning more about Adobe's great tool. We feature educational videos, which will help you master Adobe Flash and help you get to know all of its features. We at "Flash Video Training Source" believe that video training and video... more

Why don't you follow us on Twitter and get the latest video tutorials twitted to your account. Just click on the floating twitter bar to your right!

Go Back In Time
May 2012
M T W T F S S
« Apr    
 123456
78910111213
14151617181920
21222324252627
28293031  
Pretty Blank Box
top

Blogroll

  • Development Blog
  • Documentation
  • Plugins
  • Suggest Ideas
  • Support Forum
  • Themes
  • WordPress Planet

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Archives

  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
Powered by WordPress  |  Designed by Elegant Themes  |  Lightning Fast Hosting by Site 5 Hosting