logo
468x60-2-495


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

Exclusive Freebie: Custom AS3 Slider

High time we featured another exclusive freebie on Activetuts+ eh? Well here’s a great little AS3 powered Slider, completely free for use in any project you like!


AS3 Custom Slider

Here’s the sider in its simplest form:

And here it is in action, altering the contSL (contrast) property of the AdjustColor class, updating a bitmap as it does so. Check out my previous tut on the ColorMatrixFilter class to learn more about how this is done.


Features

This Slider includes the following options:

  • Custom minimum range.
  • Custom maximum range.
  • Clean and good-looking skin.
  • Displays current value.

Usage

Drag the source MovieClip and the Main.as file to your project folder and edit the desired options.

package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;

	public final class Main extends Sprite
	{
		public final function Main():void
		{
			addListeners();
		}

		private final function addListeners():void
		{
			slider.head.addEventListener(MouseEvent.MOUSE_DOWN, initDrag);
			slider.addEventListener(MouseEvent.MOUSE_UP, terminateDrag);
			stage.addEventListener(MouseEvent.MOUSE_UP, terminateDrag);
		}

		private final function initDrag(e:MouseEvent):void
		{
			slider.head.startDrag(false, new Rectangle(0, 0, slider.width - slider.head.width, 0));
			slider.addEventListener(MouseEvent.MOUSE_MOVE, onSliderMove);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onSliderMove);
		}

		private final function onSliderMove(e:MouseEvent):void
		{
			slider.head.txtTF.text = slider.head.x; //Use your custom range here
			slider.head.txt2TF.text = slider.head.x; //Use your custom range here

			/* Live Action here: this action will be updated as soon as you move the slider */
		}

		private final function terminateDrag(e:MouseEvent):void
		{
			slider.head.stopDrag();
			slider.removeEventListener(MouseEvent.MOUSE_MOVE, onSliderMove);
			stage.removeEventListener(MouseEvent.MOUSE_MOVE, onSliderMove);

			/* Action here: this action will be updated when the mouse button is released */
		}
	}
}



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