Controlling Position with the Slider Component

A Complete Slider Component Tutorial
Say Web Tutorial
My name is Avraham Saltoun and I am the web master at http://say-web.com where HD Action Script Tutorials are created and produced. I am a certified programmer technician and I live in Jerusalem, Israel
View all articles by Say Web TutorialAll SWF files are CLIENT applications. This means unlike PHP it runs on the locally on the site visitors computer. This involves several security concerns since we never know who wrote the SWF, making any internet client language very hard to create. Currently Flash and ActionScript are by far the most popular and powerful client and internet language. To leverage this power lets take a look at the SLIDER component.
Components Menu Panel. To find the SLIDER component, the procedure is similar to most components. Ask for Windows-> Components. Once you drag and drop sliders into stage make sure to give unique INSTANCE NAMES to each one of them. Instance names is the way we refer to stage items in ActionScript.

Component Property Inspector. The SLIDER like any other component has a set of properties. To access these properties, againg Windows -> Component Inspector

Now we want 2 sliders reflect the X (Horizontal) coordinate and the Y (Vertical) Coordinate so, therefore their MAXIMUM value should be correspondent or proportional to the Width (Horizontal) and Height (Vertical) of the give stage sizer. To find these values, click on the stage and check the properties Window. It is possible to use the FREE TRANSFORM tool to the slider, so if you want to rotate, stretch or squeeze, go ahead!

Note that the REGISTRATION point of any symbol is located at upper left hand corner that this will define the center. So unless the registration point is centered there will be situations where the symbol will be completely outside of the stage.

Now we are set to go.
HERE IS THE SOURCE CODE!
//The ActionScript 3.0 The Slider Component
// Avraham Saltoun
// solutions at say-web dot com
// FREE to USE, COPY and DISTRIBUTE
import fl.controls.Slider;
import fl.events.SliderEvent;
// This will import slider
// properties, methods and events
xSlider.value = ball.x;
ySlider.value = ball.y;
//This will adjust the sliders
// to hold the value of the
// coordinates of present location
xSlider.addEventListener (SliderEvent.CHANGE, sliderChange);
ySlider.addEventListener (SliderEvent.CHANGE, sliderChange);
//Both Sliders will go to the same function
function sliderChange (event:SliderEvent){
switch (event.target.name){
case 'ySlider':
ball.y = event.target.value;
break;
case 'xSlider':
ball.x = event.target.value;
break;}
x_txt.text = String(ball.x);
y_txt.text = String(ball.y); }
This should be a final result:
Spread The Word
5 Responses to "Controlling Position with the Slider Component" 
|
said this on 24 Feb 2010 5:43:04 PM CST
very helpful in understan
|
|
said this on 09 Mar 2010 3:03:16 AM CST
where the actionscripts w
1. we must 2. make slider ho 3. drawing the bal 4. ActionScripts I give step-by-ste regard |
|
said this on 09 Apr 2010 12:54:51 AM CST
Hi,
I want to know how t I've created a slider us For example I want to us |
|
said this on 05 May 2010 8:15:27 AM CST
I think at least this tut
|
|
said this on 27 Aug 2010 9:03:03 AM CST
The part about where to f
For live updat |



Author/Admin)