<?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; animated buttons</title>
	<atom:link href="http://flashadvanced.com/tag/animated-buttons/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>Glowing Button Effect</title>
		<link>http://flashadvanced.com/glowing-button-effect/</link>
		<comments>http://flashadvanced.com/glowing-button-effect/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 13:44:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[animated buttons]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[glow filter]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=426</guid>
		<description><![CDATA[In this quick tutorial I am going to show you how to create a nice glowing button effect using Flash and few lines of AS3 code in order to control the button. Let&#8217;s get started 1. Open a new Flash document and save it under &#8220;GlowingButton.fla&#8221;. Set the color to #000000 and the frame rate [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=426"><br />
<img src="http://flashadvanced.com/wp-content/upload/glowing/glowing.jpg" /><br />
</a></p>
<p>In this <strong>quick tutorial</strong> I am going to show you how to create a nice glowing button effect using Flash and few lines of AS3 code in order to control the button. Let&#8217;s get started</p>
<p><span id="more-426"></span></p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;GlowingButton.fla&#8221;. Set the color to #000000 and the frame rate to 24 fps.</p>
<p><span style="color: #ff0000;">2.</span> Take the rectangle tool and from the properties panel set the values like this:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/glowing/properties.jpg" /></p>
<p>Choose #FFCC00 for color and draw a rectangle with size 120px wide by 30px high. Now take the Selection tool and select the half of the rectangle like this:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/glowing/selection.jpg" /></p>
<p>Change the color of the selected half to #FDD535. The button background is now ready. Nice effect, right?</p>
<p><span style="color: #ff0000;">3.</span> Select the whole rectangle and convert it to Movie Clip symbol. Type &#8220;golden_btn&#8221; for instance name. Now double click the movie clip to go inside its timeline. Once again, select the whole rectangle and convert it to Movie Clip symbol.</p>
<p><span style="color: #ff0000;">4.</span> Click on frame 20 and convert it to <strong>Keyframe</strong>. Now, on frame 20, select the movie clip, then open the Filters Panel and select the <strong>Glow</strong> filter like this:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/glowing/filter.jpg" /></p>
<p>For filter color choose #FFCC00.<br />
Now select a frame between frame 1 and 20 and create <strong>Motion Tween</strong>. From the properties panel set the tween <strong>easing</strong> to 100. Select the whole 20 frames and then by right clicking select Copy Frames:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/glowing/copy.jpg" /></p>
<p>Select frame <strong>21</strong> and by right clicking select Paste Frames.<br />
Now select the copied frames and again by right clicking select Reverse Frames.</p>
<p><span style="color: #ff0000;">5.</span> Create new layer called &#8220;text&#8221;. Take the text tool and type something. For font choose Tahoma, bold, size 18, color #990000. Convert the text field to movie clip. Click on frame 20 and convert it to Keyframe.<br />
When you are still on frame 20, select the text field movie clip, go to Properties Panel and under Color choose <strong>Tint</strong>. For color choose #000000:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/glowing/tint.jpg" /></p>
<p>Click somewhere between frame 1 and frame 20 and create Motion Tween. Repeat the step where you copy, paste and reverse the frames.</p>
<p><span style="color: #ff0000;">6.</span> Create a new layer called &#8220;actions&#8221; and convert frame 20 and 40 to Keyframes. On frames 1, 20, 40 open the actions panel and type &#8220;<strong>stop();</strong>&#8220;.</p>
<p>Our glowing button is ready! All we have to do is to go back to the main Scene and type some actionscript.</p>
<p><span style="color: #ff0000;">7.</span> On the main Scene, create a new layer called &#8220;actions&#8221; and open the Actions Panel.</p>
<pre><code>
//setting the button properties
golden_btn.mouseChildren = false;
golden_btn.buttonMode = true;

//adding event listeners to our button
golden_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
golden_btn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
golden_btn.addEventListener(MouseEvent.CLICK, mouseClickHandler);

function mouseOverHandler(e:MouseEvent):void{
	golden_btn.gotoAndPlay(2);
}

function mouseOutHandler(e:MouseEvent):void{
	golden_btn.gotoAndPlay(21);
}

function mouseClickHandler(e:MouseEvent):void{
	//navigating to URL on click
	navigateToURL(new URLRequest("http://flashadvanced.com"));
}
</pre>
<p></code></p>
<p>That's all!</p>
<h4>Here is the final result:</h4>
<p><object width="150" height="60"><param name="movie" value="http://flashadvanced.com/wp-content/upload/glowing/GlowingButton.swf"><embed src="http://flashadvanced.com/wp-content/upload/glowing/GlowingButton.swf" width="150" height="60"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/glowing/glowing.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/glowing-button-effect/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Animated buttons with AS3</title>
		<link>http://flashadvanced.com/animated-buttons-with-as3/</link>
		<comments>http://flashadvanced.com/animated-buttons-with-as3/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 12:10:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[animated buttons]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=248</guid>
		<description><![CDATA[Today I will show you how to create cool animated buttons using Flash CS3 and ActionScript 3. Let&#8217;s get started! 1. Create a new Flash CS3 document with size 600 x 100 and a dark background color. 2. Take the rectangle tool and draw a rectangle with size 100 x 30. We will use it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=248"><br />
<img src="http://www.flashadvanced.com/wp-content/upload/animbtn/animbtn.jpg" /><br />
</a></p>
<p>Today I will show you how to create cool animated buttons using Flash CS3 and ActionScript 3.<br />
Let&#8217;s get started!</p>
<p><span id="more-248"></span></p>
<p><span style="color:#ff0000;">1.</span> Create a new Flash CS3 document with size 600 x 100 and a dark background color.<br />
<span style="color:#ff0000;">2.</span> Take the rectangle tool and draw a rectangle with size 100 x 30. We will use it for an invisible button. Convert the rectangle to Button symbol and give it an instance name &#8220;clickArea&#8221;. Go to the button&#8217;s timeline and drag the keyframe like shown in the picture. </p>
<p><img src="http://www.flashadvanced.com/wp-content/upload/animbtn/invbtn.jpg" /></p>
<p><span style="color:#ff0000;">3.</span> Convert the invisible button to Movie Clip with registration point top left and <strong>linkage</strong> it to a class named &#8220;Button&#8221;. Go to the new created movie clip&#8217;s timeline. Rename the invisible button&#8217;s layer to &#8220;click area&#8221;. Select frame 10 and insert frame. Then under this layer create a new layer called &#8220;label&#8221;. Create a new dynamic text field with instance name &#8220;label&#8221;. Don&#8217;t forget to <strong>embed the fonts</strong>. Convert the text field to movie clip with instance name item_label. Now select frame 10 and convert it to keyframe. On this frame you have to change the label&#8217;s position. So move the label few pixels up. Now select a frame between first and last frame and create <strong>motion tween</strong>. In the properties panel choose 100 for easing. Finally, the last step. Take the rectangle tool and draw a rectangle with size 100 x 30, choose &#8220;no stroke&#8221; and for fill color choose #CCCCCC. Place it in the same position as the invisible button. Convert it to movie clip with instance name &#8220;anim&#8221;. Select frame 10 and convert it to movie clip. In the properties panel select <strong>&#8220;Tint&#8221;</strong> for color and choose #99FF00 at 80%. Go back to frame 1, select the movie clip, go to the properties panel again and choose Alpha = 0% for color. Click somewhere between frame 1 and 10 and insert Motion Tween with Easing = 100.<br />
That was all! Our button is ready. Go back to the main timeline, remove the button from the stage and create a new layer called &#8220;actions&#8221;.<br />
<span style="color:#ff0000;">4.</span> Open the actions panel.</p>
<pre><code>
//setting the frame rate to 60 fps
stage.frameRate = 60;
//creating an array for our items
var menuArray:Array = new Array("Home", "About",
		"Tutorials|http://flashadvanced.com", "Articles", "Sources");
//spacing between the items
var spacing:Number = 5;
//we create a container for the items
var menuContainer:MovieClip = new MovieClip();
//adding the container to the stage
stage.addChild(menuContainer);

//we are looping through the menuArray
for(var i:int = 0; i < menuArray.length; i++){
	//creating a new Button class instance
	var btn:Button = new Button();
	//placing the buttons on the stage
	btn.x = 35 + (btn.width + spacing) * i;
	btn.y = 35;
	btn.itemNumber = i;
	//we check the button status every frame
	btn.addEventListener(Event.ENTER_FRAME, buttonStatus);
	//we want to split the buttons array so we can get both "label" and "URL"
	var splitArr:Array = menuArray[i].split("|");
	//the first element of the new array is the label of our button
	btn.item_label.label.text = splitArr[0];
	//the second is the URL address
	btn.itemURL = splitArr[1];
	//adding the buttons to the container
	menuContainer.addChild(btn);
}

function mouseOverHandler(e:MouseEvent):void{
	//if the cursor is over the button we set the "over" status to "true"
	e.target.over = true;
}

function mouseOutHandler(e:MouseEvent):void{
	//in the other case we set it to "false"
	e.target.over = false;
}

function mouseClickHandler(e:MouseEvent):void{
	var mc = e.target.parent;
	//on click we navigate to the specified URL
	if( mc.itemURL != undefined )
		navigateToURL(new URLRequest(mc.itemURL));
	else
		changePage(mc.itemNumber);
}

function buttonStatus(e:Event):void{
	var mc = e.target;
	//we check the button status
	if(mc.over == true)
		//if the cursor is over the button we play the animation
		mc.nextFrame();
	else
		//else we go to the previous frames
		mc.prevFrame();
}

function changePage(num:int):void{
	//we loop through the objects of our container
	for( var i:int = 0; i < menuContainer.numChildren; i++ ){
		var mc:MovieClip = MovieClip(menuContainer.getChildAt(i));
		mc.over = false;
		mc.clickArea.visible = true;
		//adding event listeners
		mc.addEventListener(MouseEvent.ROLL_OVER, mouseOverHandler);
		mc.addEventListener(MouseEvent.ROLL_OUT, mouseOutHandler);
		mc.addEventListener(MouseEvent.CLICK, mouseClickHandler);
	}

	var mcSelected = MovieClip(menuContainer.getChildAt(num));
	//when selected the button is not clickable
	mcSelected.over = true;
	mcSelected.clickArea.visible = false;
	//we remove the event listeners from the selected item
	mcSelected.removeEventListener(MouseEvent.ROLL_OVER, mouseOverHandler);
	mcSelected.removeEventListener(MouseEvent.ROLL_OUT, mouseOutHandler);
	mcSelected.removeEventListener(MouseEvent.CLICK, mouseClickHandler);

}

//we go to the homepage by default
changePage(0);
</code></pre>
<h4>Here is the final result:</h4>
<p><object width="600" height="100"><param name="movie" value="http://flashadvanced.com/wp-content/upload/animbtn/animBtn.swf"><embed src="http://flashadvanced.com/wp-content/upload/animbtn/animBtn.swf" width="600" height="100"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/animbtn/animbtn.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/animated-buttons-with-as3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

