<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flash, Flex and ActionScript tutorials - flashadvanced &#187; slider</title>
	<atom:link href="http://flashadvanced.com/tag/slider/feed/" rel="self" type="application/rss+xml" />
	<link>http://flashadvanced.com</link>
	<description>Become an advanced actionscript developer</description>
	<lastBuildDate>Sun, 30 Jan 2011 21:10:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Flash CS3 components, Part 2</title>
		<link>http://flashadvanced.com/using-flash-cs3-components-part-2/</link>
		<comments>http://flashadvanced.com/using-flash-cs3-components-part-2/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 15:04:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[rotate]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=334</guid>
		<description><![CDATA[Today I will show you how to create a nice flash application using the Slider component. This slider will be used to rotate and scale objects on the stage. 1. Open a new Flash document and save it under &#8220;slidercomponent.fla&#8221;. 2. Rename the first layer to &#8220;figures&#8221; and draw a rectangle and a pentagon. 3. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=334"><br />
<img src="http://flashadvanced.com/wp-content/upload/components/comp2.jpg" /><br />
</a></p>
<p>Today I will show you how to create a nice flash <strong>application</strong> using the <strong>Slider</strong> component. This slider will be used to rotate and scale objects on the stage.</p>
<p><span id="more-334"></span></p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;slidercomponent.fla&#8221;. </p>
<p><span style="color: #ff0000;">2.</span> Rename the first layer to &#8220;figures&#8221; and draw a rectangle and a pentagon.</p>
<p><span style="color: #ff0000;">3.</span> Convert the two figures to Movie Clips with registration points center. Give the rectangle instance name &#8220;rect&#8221; and the pentagon &#8211; &#8220;pent&#8221;.</p>
<p><span style="color: #ff0000;">4.</span> Create a new layer called &#8220;sliders&#8221;. Go to the Components by clicking Window -> Components. Drag two <strong>Slider components</strong> to the stage and position them under the figures. Give the first slider instance name &#8220;sliderrect&#8221; and the second &#8211; &#8220;sliderpent&#8221;.</p>
<p><span style="color: #ff0000;">5.</span> Create a new layer called &#8220;txt fields&#8221; and create two dynamic text fields and place them under the sliders. Give the first text field instance name &#8220;angle_txt&#8221; and the second &#8220;scale_txt&#8221;. Don&#8217;t forget to embed the font you use:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/components/embed.jpg /></p>
<p><span style="color: #ff0000;">6.</span> Now, create a new layer called &#8220;actions&#8221; and open the actions panel.</p>
<pre><code>
//importing SliderEvent class
import fl.events.SliderEvent;

//adding event listener to the first slider
sliderrect.addEventListener(SliderEvent.CHANGE, rotateObject);
//setting slider's maximum value to 100
sliderrect.maximum = 100;
/*boolean value that indicates whether the SliderEvent.CHANGE event
	is dispatched continuously as the user moves the slider thumb*/
sliderrect.liveDragging = true;
//adding event listener to the second slider
sliderpent.addEventListener(SliderEvent.CHANGE, scaleObject);
//setting slider minimum value to 1 because we don't want our object to disappear
sliderpent.minimum = 1;
//setting default slider thumb's position
sliderpent.value = 5;
sliderpent.liveDragging = true;

function rotateObject(e:SliderEvent):void{
	/*we create a variable that stores slider's value (from 0 to 100) multiplied by 3.6
		so that the variable returns values from 0 to 360*/
	var rotVal:int = (sliderrect.value)*3.6;
	//setting rectangle's rotation
	rect.rotation = rotVal;
	//rotation info
	angle_txt.text = rotVal.toString();
}

function scaleObject(e:SliderEvent):void{
	//dividing event target value by 5 because we don't want too big figures
	pent.scaleX = e.target.value / 5;
	pent.scaleY = e.target.value / 5;
	//scale info
	scale_txt.text = (e.target.value / 5).toString();
}
</code></pre>
<p>That was all!</p>
<h4>Here is the final result:</h4>
<p><object width="400" height="220"><param name="movie" value="http://flashadvanced.com/wp-content/upload/components/slidercomponent.swf"><embed src="http://flashadvanced.com/wp-content/upload/components/slidercomponent.swf" width="400" height="220"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/components/slidercomponent.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/using-flash-cs3-components-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

