<?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>mikestickney.com &#187; Flash Tutorial</title>
	<atom:link href="http://mikestickney.com/wordpress/category/flash-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikestickney.com/wordpress</link>
	<description></description>
	<lastBuildDate>Tue, 24 Aug 2010 01:25:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New Flash Tutorial Site</title>
		<link>http://mikestickney.com/wordpress/new-flash-tutorial-site/</link>
		<comments>http://mikestickney.com/wordpress/new-flash-tutorial-site/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 17:18:49 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Resources]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Mike's Opinions]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Flash tutorials]]></category>
		<category><![CDATA[gotoAndLearnFlash]]></category>
		<category><![CDATA[learn flash]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/?p=37</guid>
		<description><![CDATA[I&#8217;ve been working in my (very limited) free time on a new site for Flash tutorials. About a month ago, I did a soft-launch of www.gotoandlearnflash.com.

The goal of gotoAndLearnFlash is to have users find the Flash tutorials they want, and write their own reviews to let future readers of this site know whether the tutorial [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working in my (very limited) free time on a new site for Flash tutorials. About a month ago, I did a soft-launch of <a title="Flash tutorials on gotoAndLearnFlash.com" href="http://www.gotoandlearnflash.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.gotoandlearnflash.com');">www.gotoandlearnflash.com</a>.<br />
<span id="more-37"></span></p>
<p>The goal of <a title="Flash tutorials at gotoandlearnflash.com" href="http://www.gotoandlearnflash.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.gotoandlearnflash.com');" target="_blank">gotoAndLearnFlash</a> is to have users find the Flash tutorials they want, and write their own reviews to let future readers of this site know whether the tutorial was really helpful or not. While my goal here is to find the best free online Flash tutorials the net has to offer, I simply don’t have the time to review each and every tutorial I come across. That is why I encourage users to check out the tutorials, come back and rate or review them for future readers.</p>
<p>Currently, there are only a few tutorials listed, but I try to add more and more when I can. The biggest hurdle is I really would like to review any tutorials that I post, but I simply don&#8217;t have the time. So, I&#8217;ve been posting some Flash tutorials without an editorial review in hopes that users will add their own reviews in the comments section. Better than a rating system, I believe a user review will help gauge whether the tutorial is really worth checking out. If you enjoy my tutorials, check out <a title="Flash tutorials at gotoandlearnflash.com" href="http://www.gotoandlearnflash.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.gotoandlearnflash.com');" target="_blank">www.gotoandlearn.com</a> to find more Flash tutorials from other authors that I found helpful.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/new-flash-tutorial-site/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Breakout Game Tutorial Part 5</title>
		<link>http://mikestickney.com/wordpress/flash-game-tutorial-part-5/</link>
		<comments>http://mikestickney.com/wordpress/flash-game-tutorial-part-5/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 18:24:05 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Graphic design]]></category>
		<category><![CDATA[Mike's Opinions]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[logo design]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[Flash ActionScript tutorial]]></category>
		<category><![CDATA[flash games]]></category>
		<category><![CDATA[Flash tutorials]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/?p=34</guid>
		<description><![CDATA[Flash Tutorial: Creating a Brick Breaking Paddle Game in Flash: Part 5
Level: This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Creating a Brick Breaking Paddle Game in Flash: Part 5</p>
<p><strong>Level:</strong> This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p style="text-align: left;"><strong>Description:</strong> The fifth part of a Flash tutorial on making a Flash game similar to the old BreakOut game for Atari. In previous parts, we <a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/"  target="_self">created the movement for the paddle and the ball</a>, <a href="http://mikestickney.com/wordpress/flash-tutorial-flash-game/" >set up the bricks and the script for collisions</a>, <a href="http://mikestickney.com/wordpress/flash-tutorial-game-scores/" >added scores to our Flash game,</a> and in our <a href="http://mikestickney.com/wordpress/akflash-tutorial-flash-game-development/" >last tutorial</a>, we set it up to go to a &#8220;You Win&#8221; screen. In this tutorial, we will set up a players &#8220;lives&#8221;, as well as what will happen when the player runs out of lives.</p>
<p><span id="more-34"></span><strong>Demo:</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="250" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://mikestickney.com/flash/breakthru_game5.swf" /><embed type="application/x-shockwave-flash" width="300" height="250" src="http://mikestickney.com/flash/breakthru_game5.swf"></embed></object><br />
(Refresh page if you don&#8217;t see the ball animation)</p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Let&#8217;s open up our Flash files from <a title="Flash Tutorial: Breakthru Flash Game Part 4" href="http://mikestickney.com/wordpress/akflash-tutorial-flash-game-development/"  target="_self">Part 4 of this game tutorial</a>. While it&#8217;s not necessary, you may want to do a &#8220;Save As&#8221; and give your document a new name (&#8220;breakthru_game5.fla&#8221;). The reason you may want to do this is it might make it easier to review each part of the Flash tutorial later.</p>
<p>In our <a href="http://mikestickney.com/wordpress/akflash-tutorial-flash-game-development/" >last tutorial</a>, we set our Flash game to go to a new frame when the player &#8220;wins&#8221; the game (or clears the board). Now, we want our Flash movie to change if the player &#8220;loses&#8221; the game. By &#8220;losing&#8221; the game, we simply mean the player has run out of &#8220;lives&#8221; (or balls). So, the first thing we need to do is set up some new text boxes to display our players lives. This is done similarly to how we set up the score text in <a href="http://mikestickney.com/wordpress/flash-tutorial-game-scores/" >Part 3 of this Flash tutorial</a> series. In fact, to get started, we are going to do a copy/paste of the text we set up.</p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Click on frame 1 of our main timeline (Scene 1), and be sure your &#8220;score text&#8221; label is not locked. On the stage, select both the static text box (where it says &#8220;Score&#8221;) and the dynamic text box (the box with the dotted line around it) (Fig. 1). Tip: It may be easier to select these if you lock all the other layers except your &#8220;score text&#8221; layer.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut15_fig1.gif" alt="Flash Game Tutorial Fig. 1" /></p>
<p>Choose &#8220;Edit &gt; Copy&#8221; (command-C) to add these items to the clipboard. Add a new layer above your &#8220;score text&#8221; layer and name your new layer &#8220;Player lives&#8221;. Click on frame 1 of your new layer and choose &#8220;Edit &gt; Paste&#8221; (command-V) to paste a copy of your text boxed to the stage. Position these boxes at the bottom right corner of the stage, aligned with your score text boxes. Double click on the &#8220;Score&#8221; text on the right side of the stage, and type the word &#8220;Lives&#8221;. Now, click on the dynamic text box next to the &#8220;Lives&#8221; text and in the Properties Panel (&#8220;Window &gt; Properties &gt; Properties&#8221; or command-F3) change the &#8220;var&#8221; text field to say &#8220;lives&#8221; (Fig 2). Last step is to click on frame 2 of our &#8220;Player Lives&#8221; layer, and right-click (option-click) and choose &#8220;Remove Frames&#8221; from the menu flyout.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut15_fig2.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>We now have our Player Lives text boxes ready, so now we have to add the code that will dynamically change when our paddle (player) misses the ball (player life). On our main timeline, click on frame 1 of the &#8220;actions&#8221; layer, open the Actions Panel (Windows &gt; Actions or alt-F9) and add the following code below the existing code:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">var lives = 5;</span></p>
<p>This, as you probably could guess, sets our dynamic text box with the var name of &#8220;lives&#8221; to display he number 5, where 5 is the number of chances the player has to drop the ball before losing the game.</p>
<p>Now that we assigned a number of player lives, we need to add some script that tells Flash to take away a life when the player misses the ball. On our stage, select the white circle (ball). You&#8217;ll remember in <a href="http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/" >Part 1 of our Flash game tutorial</a> we set added some script that reset our ball if the player missed the ball. In that same section of code (the <span style="color: #000080;">if</span> statement towards the bottom), we need to add some additional code to tell Flash to deduct a number from our &#8220;Lives&#8221; text box. Add the <span style="color: #000080;"><strong>bold, blue code </strong></span>below to your existing code (<span style="color: #008000;">green</span> code should have been added in part 1):</p>
<p style="padding-left: 30px;"><span style="color: #008000;">if (this._y &gt; 300) {<br />
<span style="color: #000080;"><strong>_root.lives -= 1;<br />
if (_root.lives == 0) {<br />
_root.play();<br />
}</strong></span><br />
_x = 150;<br />
_y = 100;</span></p>
<p>dir = Math.round(Math.random() * 1);<br />
speed = 10;<br />
if (dir == 1) {<br />
var Ang = 45;<br />
} else {<br />
var Ang = 135;<br />
}<br />
xspeed = speed * Math.cos((Ang) * Math.PI / 180);<br />
yspeed = speed * Math.sin((Ang) * Math.PI / 180);<br />
}<br />
}</p>
<p>Explanation of the new code:</p>
<p style="padding-left: 30px;"><span style="color: #008000;">if (this._y &gt; 300) {</span><br />
<span style="color: #008000;"><span style="color: #000080;">_root.lives -= 1<strong>;</strong></span></span></p>
<p>If our ball y coordinate is greater than 300 (goes below the paddle), subtract our &#8220;lives&#8221; by 1.</p>
<p style="padding-left: 30px;"><span style="color: #008000;"><span style="color: #000080;">if (_root.lives == 0) {<br />
_root.play();<br />
}</span></span></p>
<p>If our &#8220;lives&#8221; is equal to 0 (meaning we have no lives left), then play our main timeline.</p>
<p>Go ahead and test your movie. On start, you should see that you have &#8220;5&#8243; lives. Each time you miss a ball, you should see your lives go down by 1 number. If your lives goes all the way to 0, you should see frame 2 of your main timeline come up&#8230; but wait, it still says &#8220;You Win&#8230;&#8221;. Well, we don&#8217;t want it to say that unless we clear the board, so we need to make it say something other than that if we lose, right? Well, luckily Flash makes it pretty easy to do that.</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Click on frame 2 of the &#8220;You Win&#8221; layer in your Flash file. Select the &#8220;Congratulations&#8230;&#8221; text box, and in the properties panel, change the drop down to &#8220;Dynamic Text&#8221; and in the &#8220;Var&#8221; text field give it the name &#8220;gameOver&#8221;. You&#8217;ll notice that when you change the text box to &#8220;Dynamic Text&#8221;, the actual text in your box did not change. That&#8217;s because you can input text to a dynamic text box in Flash and have it display in your movie, but because it&#8217;s &#8220;dynamic&#8221; you can modify it using ActionScript code. So, since if the player wins, we want this text to read &#8220;Congratulations&#8230;&#8221; we will leave this. But, if the Player loses, we need it to say something else. We&#8217;ll add that code now.</p>
<p>Click on frame 2 of your &#8220;actions&#8221; layer, open your Actions Panel and add the following code below the existing code:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if (_root.lives == 0) {<br />
gameOver = &#8220;&lt;p align=&#8217;center&#8217;&gt;Sorry, you lose! &lt;br&gt;&lt;br&gt;Your Final Score Is:&lt;/p&gt;&#8221;;<br />
}</span></p>
<p>What this says is if our player lives is equal to zero, our dynamic text box should insert the text between the quotation marks. But hold on a minute&#8230; what&#8217;s with all the extra text here? Well, if your familiar with HTML code, you should recognize this as HTML markup language. That&#8217;s right, Flash can render HTML text in a dynamic text field! But, for this to happen, we need to tell our text box to render HTML code.</p>
<p>Click on frame 2 of the &#8220;You Win&#8221; layer, and select the top dynamic text box. In the Properties Panel, click on the &#8220;Render Text as HTML&#8221; button (the button with the angle brackets (&lt;&gt;) on it (Fig 3).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut15_fig3.gif" alt="Flash Game Tutorial Fig. 3" /></p>
<p>That&#8217;s it! I must say our game is looking pretty good right now, don&#8217;t you agree? We have our basic challenge of bouncing a ball into multiple bricks, we can keep score, and now we only have a certain amount of chances in order to accomplish our goal. Pretty cool. While this game seems pretty complete, there&#8217;s so much more we can do to this game, including adding a start screen, adding additional levels and making different skill levels. Study up on these tutorials, and hopefully you can figure out how to do some of these things yourself, but if not, check back soon as I plan to cover all of these steps in future tutorials!</p>
<p>Thanks for reading, and I hope you were able to follow along and create your own Flash game, and I also hope that they have given you a nice little primer for Flash game development. Good luck and don&#8217;t forget to check back soon to expand on our Flash Breakout Game!</p>
<p><strong>Source files (Flash 8):</strong> <a title="Flash Tutorial: Breakthru Flash Game Part 5" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/05/breakthru_game5.fla" >Flash Tutorial: Breakthru Flash Game Part 5</a></p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-game-tutorial-part-5/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Breakout Game Tutorial Part 4</title>
		<link>http://mikestickney.com/wordpress/akflash-tutorial-flash-game-development/</link>
		<comments>http://mikestickney.com/wordpress/akflash-tutorial-flash-game-development/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 23:36:05 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[Flash ActionScript tutorial]]></category>
		<category><![CDATA[flash games]]></category>
		<category><![CDATA[Flash tutorials]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/?p=33</guid>
		<description><![CDATA[Flash Tutorial: Creating a Brick Breaking Paddle Game in Flash: Part4
Level: This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with earlier [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Creating a Brick Breaking Paddle Game in Flash: Part4</p>
<p><strong>Level:</strong> This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p style="text-align: left;"><strong>Description:</strong> The fourth part of a Flash tutorial on making a Flash game similar to the old BreakOut game for Atari. In the <a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/"  target="_self">first part of our game tutorial</a>, we created the movement for the paddle and the ball. In the <a href="http://mikestickney.com/wordpress/flash-tutorial-flash-game/" >second part of the Flash tutorial</a>, we set up the bricks and applied the script for the collisions of the ball with the bricks. In the <a href="http://mikestickney.com/wordpress/flash-tutorial-game-scores/" >third part of our Flash game tutorial,</a> we added scores to our flash game. Now, for the fourth part of our Flash game, we will have the game advance to a new screen when we &#8220;win&#8221; the game.</p>
<p><span id="more-33"></span><strong>Demo:</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="250" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://mikestickney.com/flash/breakthru_game4.swf" /><embed type="application/x-shockwave-flash" width="300" height="250" src="http://mikestickney.com/flash/breakthru_game4.swf"></embed></object></p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Let&#8217;s open up our Flash files from <a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/flash-tutorial-game-scores/"  target="_self">Part 3 of this game tutorial</a>. While it&#8217;s not necessary, you may want to do a &#8220;Save As&#8221; and give your document a new name (&#8220;breakthru_game4.fla&#8221;). The reason you may want to do this is it might make it easier to review each part of the Flash tutorial later.</p>
<p>In our <a href="http://mikestickney.com/wordpress/flash-tutorial-game-scores/" >last tutorial</a>, we added a score using dynamic text to our Flash game. What we want to do now is have the game advance to a new screen when the player &#8220;wins&#8221; the game, or clears the board of the bricks. To do this, we will be advancing the game based on the players score. The first step in order to do this is to add the next &#8220;You Win&#8221; state (or screen) to our Flash file.</p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>On our movies main timeline (Scene 1), add a new layer called &#8220;You Win&#8221;, and move the layer under the &#8220;actions&#8221; layer. Click on frame 1 of our new layer, and add a blank keyframe (&#8220;Insert &gt; Timeline &gt; Blank Keyframe&#8221; or F6). Because we don&#8217;t want the other layers to be visible on frame 2 of our movie, select the 2 keyframe of all the layers below our &#8220;You Win&#8221; layer, and control-click (right-click) and select &#8220;Remove Frames&#8221; from the flyout menu.</p>
<p>Click on frame 2 of your &#8220;You Win&#8221; layer, select the Text Tool (T), set it to &#8220;Static Text&#8221; in your Properties Panel (&#8220;Window &gt; Properties &gt; Properties&#8221; or command-F3) and click on the stage and  type something like</p>
<p>&#8220;Congratulations! You Win!&#8221; &lt;return&gt;<br />
&#8220;Your Final Score Is:&#8221;</p>
<p>You should now have something similar to Fig. 1.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut14_fig1.gif" alt="Flash Game Tutorial Fig. 1" /></p>
<p>Select the Text Tool (T) again, and draw another text box below this text. In the Properties Panel, set the dropdown to &#8220;Dynamic Text&#8221;, in the &#8220;var&#8221; field give it a name of &#8220;scoreFinal&#8221; and select the &#8220;center align&#8221; paragraph setting (Fig 2).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut14_fig2.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>Remember that in our previous tutorial, we added a <span style="color: #000080;">stop();</span> action to frame 1 of our &#8220;actions&#8221; layer in our main timeline. So, if we were to test our movie now, we would still only be able to play our game and we would never see the &#8220;You Win&#8221; frame. So, what we need to do now is add some script that tells our Flash movie to advance to the next frame IF our score equals the &#8220;winning score&#8221;.</p>
<p>Open the Library window (&#8220;Window &gt; Library&#8221; or command-L). Double click on your &#8220;mc_Brick&#8221; symbol in the library to bring up symbol editing mode. Click on frame 2 of the actions layer, open the Actions Panel (&#8220;Window &gt; Actions&#8221; or alt-F9) and add the following code under the existing code:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if (_root.score == 160) {<br />
_root.play();<br />
}</span></p>
<p>What this is saying is if the dynamic text box on the main timeline with the var name &#8220;score&#8221; (which we set  up in our <a href="http://mikestickney.com/wordpress/flash-tutorial-game-scores/" >previous tutorial</a>) is equal to 160, than play our main timeline. We use 160 because there are 16 bricks worth 10 points each: 16 x 10 = 160. So, in order for our score to equal 160, all the bricks must be hit by our ball. Once that is done, we advance to the next frame of our main timeline (<span style="color: #000080;">_root</span>), if our score is less than 160, we remain on frame 1 of our main timeline (because of the <span style="color: #000080;">stop();</span> action we already applied).</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Return to Scene 1 of your movie. Click on frame 2 of our &#8220;actions&#8221; layer and add a blank keyframe. With frame 2 still selected, open the actions panel and add the following code:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">stop();</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">scoreFinal = score;</span></p>
<p>What this code does is stops our movie on frame 2 and sets our dynamic text box with a var name of &#8220;scoreFinal&#8221; (which we set earlier in this tutorial) to be the same as whatever the text is in our text box with the variable name of &#8220;score&#8221;. Of course you could simply say &#8220;<span style="color: #000080;">scoreFinal = 160</span>&#8220;, since we know that the score is 160 if they hit this frame, but I&#8217;m going to set it dynamically in order to give you a teaser for the next part of this series which is what happens if a player loses. After all, what fun is a game that you ALWAYS win??</p>
<p>For now, go ahead and test your movie. The game should play just like it did at the end of the last tutorial, but now when you have all the bricks cleared, you should see the &#8220;Congratulations&#8230;&#8221; text. Obviously, this &#8220;You Win&#8221; page isn&#8217;t the most exciting thing in the world, so I would hope that you might play around and stylize this on your own.</p>
<p>I hope you enjoyed this tutorial, and hopefully you&#8217;ll come back soon for the next part of the game tutorial. Thanks for reading, and if you have trouble, the commented source file is available below to help you along.</p>
<p>Continue to <a title="Flash Game Tutorial part 5" href="http://mikestickney.com/wordpress/flash-game-tutorial-part-5/" >Part 5 &gt;&gt;</a></p>
<p><strong>Source Files (Flash 8): </strong><a title="Flash Tutorial: Breakthru Flash Game Part 2" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/05/breakthru_game4.fla" >Flash Tutorial: Breakthru Flash Game Part 4</a></p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/akflash-tutorial-flash-game-development/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Breakout Game Tutorial Part 3</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-game-scores/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-game-scores/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 01:09:00 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[Flash ActionScript tutorial]]></category>
		<category><![CDATA[flash games]]></category>
		<category><![CDATA[Flash tutorials]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/?p=32</guid>
		<description><![CDATA[Flash Tutorial: Creating a Brick Breaking Paddle Game in Flash: Part 3
Level: This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Creating a Brick Breaking Paddle Game in Flash: Part 3</p>
<p><strong>Level:</strong> This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p style="text-align: left;"><strong>Description:</strong> The third part of a Flash tutorial on making a Flash game similar to the old BreakOut game for Atari. In the <a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/category/actions-script-tutorial/"  target="_self">first part of our game tutorial</a>, we created the movement for the paddle and the ball. In the <a href="http://mikestickney.com/wordpress/flash-tutorial-flash-game/" >second part of the Flash tutorial</a>, we set up the bricks and applied the script for the collisions of the ball with the bricks. In this part of our Flash game tutorial, we will set up the game score using dynamic text.</p>
<p><span id="more-32"></span><strong>Demo:</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="250" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://mikestickney.com/flash/breakthru_game3.swf" /><embed type="application/x-shockwave-flash" width="300" height="250" src="http://mikestickney.com/flash/breakthru_game3.swf"></embed></object></p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Let&#8217;s open up our Flash files from <a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/flash-tutorial-flash-game/"  target="_self">Part 2 of this game tutorial</a>. While it&#8217;s not necessary, you may want to do a &#8220;Save As&#8221; and give this your document a new name (&#8220;breakthru_game3.fla&#8221;). The reason you may want to do this is it might make it easier to review each part of the Flash tutorial later.</p>
<p>In our <a href="http://mikestickney.com/wordpress/flash-tutorial-flash-game/" >last tutorial</a>, we added the bricks for us to try and direct the ball into. What now should happen is when the ball hits a brick, that brick will disappear, and the ball will reverse angle and direction. Now, what we want to happen is in addition to the brick disappearing, we want it to add points to our game score.</p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Since we will be adding our game scores to the bottom of the stage, the first thing we will do is move our paddle up about 25 pixels from the bottom of the stage. Now, lets add a new layer to our timeline under the &#8220;actions&#8221; layer, and name it &#8220;background&#8221;. With the Rectangle Tool (R), draw a rectangle (any color you wish, I&#8217;ve used a purple), with no stroke, approximately 25 pixels tall across the width of your stage (Fig 1).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut13_fig1.gif" alt="Flash Game Tutorial Fig. 1" width="323" height="290" /></p>
<p>Add a new layer above your new rectangle, and label it &#8220;score text&#8221;. Next, select the Text Tool (T), and in the lower left corner of the stage, click on the stage and type &#8220;Score:&#8221; in white letters. Click on the text and in Properties Panel (&#8220;Window &gt; Properties &gt; Properties&#8221; or command-F3) be sure to select &#8220;Static Text&#8221; from the dropdown (Fig 2).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut13_fig2.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>Again, using the Text Tool, draw a rectangle next to your text, and in the Properties Panel select &#8220;Dynamic Text&#8221; from the drop down, and in the &#8220;var&#8221; text field, type the word &#8220;score&#8221; (Fig 3).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut13_fig3.gif" alt="Flash Game Tutorial Fig. 3" /></p>
<p>Here&#8217;s a quick little explanation on &#8220;Dynamic Text&#8221; vs. &#8220;Static Text&#8221;. When we use &#8220;static text&#8221;, whatever we type in the text box will remain exactly what we typed in Flash when we publish the Flash movie. So, for items that we know will never need to change, we can use the &#8220;static text&#8221; option. With &#8220;dynamic text&#8221;, our text can change based on ActionScript that we set in our Flash movie, using the &#8220;var&#8221; name (in this case, &#8220;score&#8221;). There are multiple ways to input and display Dynamic Text fields (including importing from an XML file and even formatting as HTML), however that is way beyond the scope of this tutorial, but I thought a quick explanation of the difference would be appropriate. Tip: A dynamic text box will have a dotted line around it (as long as the layer is unlocked), while a static text field will not have a box (unless it&#8217;s clicked on) (Fig 4). Also, you can add text to a dynamic text box, and what you type will display in Flash when you publish the Flash movie (until we add code to change it&#8230;.)</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut13_fig4.gif" alt="Flash Game Tutorial Fig. 4" /></p>
<p>What we&#8217;ll do now is set our score to be 0 (zero) when the game starts. To do this, on the main timeline, click on frame 1 of your &#8220;actions&#8221; layer, open the Actions Panel, and under the &#8220;stop();&#8221; actions, add the following code:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">var score=0;</span></p>
<p>What this code is doing is making our dynamic text box with the var name of &#8220;score&#8221; display a zero when the movie opens.</p>
<p>Now that we have our dynamic score box, we will need to add the code to change our score when we hit the brick. We will be adding this code to our &#8220;mc_Brick&#8221; movie clip. Open the Symbol Library (&#8220;Window &gt; Library&#8221; or command-L). In the Library panel, double click on the &#8220;mc_Brick&#8221; symbol to bring it into symbol editing mode. Click on frame 2 of the &#8220;actions&#8221; layer, open your Actions Panel (Window &gt; Actions or alt-F9), and add the following code under the stop(); action:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">_root.score += 10;<br />
</span></p>
<p>What this is saying is when we get to this frame, add 10 points to the number in our dynamic text box with a var of &#8220;score&#8221; that we set on our main timeline.</p>
<p>That&#8217;s it! We now can keep score for our Flash game. Pretty simple, huh?</p>
<p>Check back soon for Part 4 of our game tutorial where we will have the game change when we &#8220;win&#8221; (i.e. clear all the bricks) the game.</p>
<p>I hope you enjoyed this tutorial. As always, the source files (with comments) can be found below.</p>
<p>Continue to <a title="Flash Game Tutorial part 4" href="http://mikestickney.com/wordpress/akflash-tutorial-flash-game-development/" >Part 4 &gt;&gt;</a></p>
<p><strong>Source Files (Flash 8): </strong><a title="Flash Tutorial: Breakthru Flash Game Part 2" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/05/breakthru_game3.fla" >Flash Tutorial: Breakthru Flash Game Part 3</a></p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-game-scores/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Breakout Game Tutorial Part 2</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-flash-game/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-flash-game/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 23:46:06 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[Flash ActionScript tutorial]]></category>
		<category><![CDATA[flash games]]></category>
		<category><![CDATA[Flash tutorials]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/?p=31</guid>
		<description><![CDATA[Flash Tutorial: Creating a Brick Breaking Paddle Game in Flash: Part 2
Level: This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Creating a Brick Breaking Paddle Game in Flash: Part 2</p>
<p><strong>Level:</strong> This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p style="text-align: left;"><strong>Description:</strong> In this tutorial, I will explain the second part of making a game similar to the old BreakOut game for Atari. In the <a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/"  target="_self">previous part</a>, we created the movement for the paddle and the ball. In this part, we will set up the bricks and apply the script for the collisions of the ball with the bricks.</p>
<p><span id="more-31"></span><strong>Demo:</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="250" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://mikestickney.com/flash/breakthru_game2.swf" /><embed type="application/x-shockwave-flash" width="300" height="250" src="http://mikestickney.com/flash/breakthru_game2.swf"></embed></object></p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Let&#8217;s open up our Flash files from <a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/"  target="_self">Part 1 of this game tutorial</a>. While it&#8217;s not necessary, you may want to do a &#8220;Save As&#8221; and give this your document a new name (&#8220;breakthru_game2.fla&#8221;). The reason you may want to do this is it might make it easier to review each part of the tutorial later.</p>
<p>In our last tutorial, we set up the movement of the ball and the paddle. The ball bounces around the stage, and when it hits either side, or the top of the stage, it reverses angle and direction. The paddle is controlled by the user using the left and right arrow keys, and when the ball hits the paddle, it reverses angle and direction. Pretty neat, but not the most fun game in the world&#8230; so what we will do now is add the bricks for the us to try and direct the ball into. What we want to happen is when the ball hits a brick, that brick will disappear, and the ball will reverse angle and direction.</p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Obviously, the first thing we need to do is draw our bricks, and set them up in a &#8220;grid&#8221; type alignment similar to Fig. 1 below.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut12_fig1.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>You&#8217;ll notice we have 16 different bricks that are 4 different colors. You of course can add as many or as few bricks as you want, but for simplicity I think this is a good number. Because Flash allows us to edit certain aspects of a symbol on the stage, such as color and size, without changing the appearance of our original Library symbol, we will only need to draw our brick symbol once.</p>
<p>Select the Rectangle Tool (R), and choose no stroke (white swatch with a red line through it in the color pallette), and a fill of red (although any color is fine). Draw a rectangle on your stage approximately 75 pixels wide by 10 pixels tall. Select your rectangle using the Selection Tool (V), and choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8), and give your symbol a name of &#8220;mc_brick&#8221; and select the &#8220;Movie Clip&#8221; radial and hit &#8220;Ok&#8221;. With your mc_brick symbol still selected, again choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8), and give your symbol a name of &#8220;mc_brickHolder&#8221; and select the &#8220;Movie Clip radial and hit &#8220;OK&#8221;.</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>What you will now have is a nested movie clip (mc_brick is nested within mc_brickHolder) (Fig. 2). The reason we want to nest our &#8220;mc_brick&#8221; symbol inside the &#8220;mc_brickHolder&#8221; movie clip is because all of our bricks on the stage will be using the same ActionScript code. By nesting our brick symbol in a holder mc, we will only need to apply our ActionScript once (within the holder clip). While we could place each &#8220;mc_brick&#8221; symbol on the stage the same way we will the holder, if we did it that way we would need to add the ActionScript to each instance of our brick (16)&#8230; and if we need to trouble shoot, we would be trouble shooting our script 16 times. This way, we only need to add the code once, and if we need to modify the code, we only need to modify it once. I know that explanation might be a little confusing, but hopefully it makes more sense by the time you get to the end of this tutorial.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut12_fig2.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>From the Library window (&#8220;Window &gt; Library&#8221; or command-L), click on your &#8220;mc_brick&#8221; symbol to bring it into sybmol editing mode. Add a new layer and label it &#8220;actions&#8221;, and name the layer with your rectangle &#8220;brick&#8221;. In frame 2, add a new keyframe (&#8220;Insert &gt; Timeline &gt; Keyframe&#8221; or F6) to both layers. Select frame 1 of your actions layer, open the Actions Panel (&#8220;Window &gt; Actions&#8221; or alt-F9), and place a stop action here:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">stop();</span></p>
<p>Input another stop action on Frame 2 of the actions layer. On Frame 2 of your brick layer, delete the rectangle from the stage. Your timeline for this symbol should now look similar to Fig. 3 below.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut12_fig3.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>Now, from the Library window, click on the &#8220;mc_brickHolder&#8221; symbol to bring it into symbol editing mode. This is where we will be adding the Action Script that controls what will happen when our ball comes into contact with our brick. On the stage, click on the rectangle ONCE (clicking twice will bring you into &#8220;mc_brick&#8221; symbol editing mode, which is what we don&#8217;t want). Tip: if you click on the symbol on the stage once, you will see a blue bounding box around the symbol. If you are in symbol editing mode, clicking on the rectangle will show whitedots within your selection (Fig 4).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut12_fig4.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>With our symbol on the stage selected, open the Actions Panel and add the following script:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">onClipEvent(enterFrame) {<br />
if ((this.hitTest(_root.ball))) {<br />
_root.ball.yspeed = -_root.ball.yspeed;<br />
this.play();<br />
}<br />
}</span></p>
<p>Here is the code explanation (which relates to the code from Part 1 of this tutorial):</p>
<p style="padding-left: 30px;"><span style="color: #000080;">onClipEvent(enterFrame) {</span></p>
<p>When we get to this frame, perform the code between the curly brackets.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if ((this.hitTest(_root.ball))) {</span></p>
<p>If our ball (&#8220;<span style="color: #000080;">_root.ball</span>&#8220;) moviclip touches (<span style="color: #000080;">&#8220;.hitTest</span>&#8220;) the brick (&#8220;<span style="color: #000080;">this</span>&#8220;), then perform the actions between the curly brackets.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">_root.ball.yspeed = -_root.ball.yspeed;</span></p>
<p>reverse the angle and direction of the ball (set in Part 1 of this tutorial)</p>
<p style="padding-left: 30px;"><span style="color: #000080;">this.play();<br />
}<br />
}</span></p>
<p>And play the brick movie clip (advancing it to the blank frame of our mc_brick symbol, essentially making our brick disappear).</p>
<p>That&#8217;s all the ActionScript needed for this tutorial. All that&#8217;s left to do now is place our bricks onto the stage.</p>
<p>Return to Scene 1 of our flash movie. Create a new layer named &#8220;bricks&#8221; and drag your &#8220;mc_brickHolder&#8221; symbol from the library to the stage. Select the symbol on the stage, and open the Info pallette (&#8220;Window &gt; Info&#8221; or command-I). Set the width to 73, the height to 10, the x to 37.5 and the y to 44 (Fig. 5).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut12_fig5.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>We now want to place this symbol 4 columns across and 4 rows up. Click on the symbol, select &#8220;Edit &gt; Copy&#8221; (command-C) and then select &#8220;Edit &gt; Paste&#8221; (command-V). This will add another instance of the symbol to your stage. Move this instance so that it sits next to your first symbol (it doesn&#8217;t have to be exact, we&#8217;ll fix it in a minute). Paste two more intances of the symbol, and align them 4 across, setting the 4th one against the right side of the stage. Now, select all 4 instances (drag your mouse over all, or &#8220;shift-click&#8221; on each symbol), and open the Align pallette (&#8220;Windows &gt; Align&#8221; or command-K). Be sure that the &#8220;To Stage&#8221; button is deselected, and click on the distribute horizontal button and the align vertical center buttons to set all 4 instances in a perfect row, equally spaced apart (Fig 6).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut12_fig6.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>With all four rectangles still selected, do another copy paste. In the Properties panel (Window &gt; Properties &gt; Properties or command F3), next to &#8220;Color&#8221;, select &#8220;Tint&#8221; from the drop down, and choose an orange color from the color pallette (Fig. 7). Position this row above the row of red rectangles (you can use the Align pallette if needed). Repeat this process 2 more times, making one set of bricks blue and one green. You should now have the grid similar to Fig 1 at the beginning of this tutorial.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut12_fig7.gif" alt="Flash Game Tutorial Fig. 2" /></p>
<p>That&#8217;s it. We are now done with our Flash game! Go ahead and test your movie and see what happens. While this is a relatively simple and basic game, I think it&#8217;s a great start to learning about Flash game development and design. I hope you enjoyed this tutorial, and have fun playing your newly created game. In a future tutorial, I will show you how to add a scoring feature, as well as player &#8220;lives&#8221;.</p>
<p>Thanks for reading!</p>
<p>Continue to <a title="Flash Game Tutorial part 3" href="http://mikestickney.com/wordpress/flash-tutorial-game-scores/" >Part 3 &gt;&gt;</a></p>
<p><strong>Source Files (Flash 8): </strong><a title="Flash Tutorial: Breakthru Flash Game Part 2" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/05/breakthru_game2.fla" >Flash Tutorial: Breakthru Flash Game Part 2</a></p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-flash-game/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Breakout Game Tutorial Part 1</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 22:42:33 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ActionScript 2.0]]></category>
		<category><![CDATA[Flash ActionScript tutorial]]></category>
		<category><![CDATA[flash games]]></category>
		<category><![CDATA[Flash tutorials]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/?p=30</guid>
		<description><![CDATA[Flash Tutorial: Creating a Brick Breaking Paddle Game in Flash
Level: This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Creating a Brick Breaking Paddle Game in Flash</p>
<p><strong>Level:</strong> This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p style="text-align: left;"><strong>Description:</strong> In this tutorial, I will explain the first part of making a game similar to the old BreakOut game for Atari. In this part, I will show you how to set up the ball and paddle movement for the demo below.</p>
<p><span id="more-30"></span><br />
<strong>Demo:</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="250" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://mikestickney.com/flash/breakthru_game.swf" /><embed type="application/x-shockwave-flash" width="300" height="250" src="http://mikestickney.com/flash/breakthru_game.swf"></embed></object></p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Select &#8220;File &gt; New&#8221; (command-&#8221;N&#8221;) and select Flash File (ActionScript 2.0) to open a new Flash document file. Save the file, and give it the appropriate name. I will call this &#8220;breakthru_game1.fla&#8221;. Feel free to change the document dimensions to whatever you like (&#8220;Modify &gt; Document&#8221; or &#8220;command-J&#8221;), but for the purpose of this tutorial, I will use 300&#215;250 pixels. Let&#8217;s also give our stage a background color of black. You can either do this using &#8220;Modify &gt; Document&#8221; (command-J), or by setting the &#8220;Background&#8221; color in your &#8220;Properties Panel&#8217; (&#8220;Window &gt; Properties &gt; Properties&#8221; or command-F3).</p>
<p>The first thing we will do is set up the ball. On the center of your stage, draw a small circle using the &#8220;Oval Tool&#8221; (&#8220;O&#8221;) approximately 15 pixels in diameter with a white fill and no stroke. (Tip: Hold &#8220;Shift&#8221; when dragging the mouse to draw a perfect circle). Select your circle and select &#8220;Modify &gt; Convert to Symbol&#8221; (F8). In the &#8220;Convert to Symbol&#8221; dialog box, give your symbol a name of &#8220;mc_ball&#8221;, and select the &#8220;Movie Clip&#8221; radial. Also be sure to select the center box in the &#8220;Registration&#8221; (Fig 1) and hit &#8220;OK&#8221;.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut11_fig1.gif" alt="Flash Game Tutorial Fig. 1" /></p>
<p>Now that our ball is a movie clip, we can add actions to it. Select your circle on the stage, and in the &#8220;Properties Panel&#8221;, give it an instance name of &#8220;ball&#8221;. With your ball still selected, open the &#8220;Actions&#8221; panel (&#8220;Window &gt; Actions&#8221; or &#8220;alt-F9&#8243;) and insert the following code (I will try to explain the code later):</p>
<p style="padding-left: 30px;"><span style="color: #000080;">onClipEvent(load) {<br />
dir = Math.round(Math.random() * 1);<br />
speed =10;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">if (dir == 1) {<br />
var Ang = 45;<br />
} else {<br />
var Ang = 135;<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">xspeed = speed * Math.cos((Ang) * Math.PI / 180);<br />
yspeed = speed * Math.sin((Ang) * Math.PI / 180);<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">onClipEvent(enterFrame) {<br />
this._x += xspeed;<br />
this._y += yspeed;<br />
if ((this._x &lt;= 5) || (this._x &gt;= 295)) {<br />
xspeed = -xspeed;<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">if ((this._y &lt;= 5) || (_root.pad.hitTest(this))) {<br />
yspeed = -yspeed;<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">if (this._y &gt; 300) {<br />
_x = 150;<br />
_y = 100;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">dir = Math.round(Math.random() * 1);<br />
speed = 10;<br />
if (dir == 1) {<br />
var Ang = 45;<br />
} else {<br />
var Ang = 135;<br />
}<br />
xspeed = speed * Math.cos((Ang) * Math.PI / 180);<br />
yspeed = speed * Math.sin((Ang) * Math.PI / 180);<br />
}<br />
}</span></p>
<p>We now have movement of our ball using ActionScript. You can go ahead and test your movie if you want (&#8220;Control &gt; Test Movie&#8221; or command-Return). The ball will move towards the bottom of the page at an angle, disappear off the bottom and then start again from the center of the stage.</p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>What we need to do now is create a &#8220;paddle&#8221; for our ball to bounce off of. For this, we will create a small rectangle, approximately 10 pixels high by 50 pixels wide, with a white fill and no stroke. Place this rectangle near the bottom edge of your stage. (Fig 2)</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut11_fig2.gif" alt="Flash Game Tutorial Fig. 2" width="340" height="320" /></p>
<p>Select your rectangle, and choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8). Give your symbol a name of &#8220;mc_paddle&#8221; and be sure to select the &#8220;Movie Clip&#8221; radial. Now, with the rectangle selected on the main stage, give it an instance name of &#8220;pad&#8221;. With your movie clip still selected, open the Actions Panel and insert the following code:</p>
<p style="padding-left: 30px;"><span style="color: #000080;">onClipEvent(enterFrame) {</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">if(Key.isDown(Key.RIGHT)) {<br />
if(this._x &lt;= 275) {<br />
this._x += 10<br />
}<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">if(Key.isDown(Key.LEFT)) {<br />
if(this._x &gt;= 25) {<br />
this._x -= 10;<br />
}<br />
}<br />
}</span></p>
<p>That&#8217;s it! We have now set up the ball and paddle movement for our game. If you test your movie, you should see the ball move as before, and you should be able to move the paddle (rectangle) from side to side with the arrow keys. When the ball hits the paddle, the top or either the left or right side, it should bounce off and move in the opposite direction. Now, I will try to explain the code and hopefully it will help you understand what is happening here. I&#8217;ve also heavily commented the source code (for those of you who are impatient), which you can download below.</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Code Explanation for the Ball (circle):</p>
<p style="padding-left: 30px;"><span style="color: #000080;">onClipEvent(load) {</span></p>
<p>When the movie clip loads, perform the actions between the curly brackets.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">dir = Math.round(Math.random() * 1);</span></p>
<p>Sets a random direction of either 0 or 1 where 0 = left, 1 = right.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">speed =10;</span></p>
<p>Sets the speed the ball will travel. Higher the number, the faster the ball will move.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if (dir == 1) {<br />
var Ang = 45;</span></p>
<p>If the direction of the ball (set randomly above) is equal to 1 (right), then the angle of the movement will be 45 degrees.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">} else {<br />
var Ang = 135;<br />
}</span></p>
<p>Otherwise, the angle of the movement will be 135 degrees.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">xspeed = speed * Math.cos((Ang) * Math.PI / 180);</span></p>
<p>Sets the x vector for the ang, and tells flash how much to move the balls x coordinate.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">yspeed = speed * Math.sin((Ang) * Math.PI / 180);<br />
}</span></p>
<p>Sets the y vector for the ang, and tells flash how much to move the balls y coordinate.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">o</span><span style="color: #000080;">nClipEvent(enterFrame) {</span></p>
<p>When the clip enters this frame, perform the actions between the curly brackets.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">this._x += xspeed;<br />
this._y += yspeed;</span></p>
<p>Sets the _x and _y coordinates to the xspeed and yspeed we determined on the onLoad above.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if ((this._x &lt;= 5) || (this._x &gt;= 295)) {<br />
xspeed = -xspeed;<br />
}</span></p>
<p>If the _x coordinate is less than five or (||) the _x coordinate is greater than 295, reverse the xspeed of the ball. Basically, what this says is if the ball hits either side of the stage, reverse the direction (change xspeed from postive to negative or vice versa). The numbers 5 (left edge) and 295 (right edge) correspond to the size of your stage and take into account that the _x coordinate of your ball is based on the center point. For the true &#8220;edge&#8221; of the stage we would use 0 and 300 (the width of the stage), but then half the ball would be off the visible area of the stage before the direction change took effect.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if ((this._y &lt;= 5) || (_root.pad.hitTest(this))) {<br />
yspeed = -yspeed;<br />
}</span></p>
<p>This is basically doing the same as our _x statement above, but is setting the _y coordinate to change direction if it hits either the top of the stage (_y&lt;=5), or if it hits the pad (_root.pad.hitTest(this))) where &#8220;this&#8221; is the ball and &#8220;_root.pad.&#8221; is the rectangle instance name.</p>
<p style="padding-left: 30px;">i<span style="color: #000080;">f (this._y &gt; 300) {</span></p>
<p>if the ball goes below the bottom of the stage (greater than 300, our stage height of 250 plus a little extra so there is a slight pause when we miss it)</p>
<p style="padding-left: 30px;"><span style="color: #000080;">_x = 150;<br />
_y = 100;<br />
dir = Math.round(Math.random() * 1);<br />
speed = 10;<br />
if (dir == 1) {<br />
var Ang = 45;<br />
} else {<br />
var Ang = 135;<br />
}<br />
xspeed = speed * Math.cos((Ang) * Math.PI / 180);<br />
yspeed = speed * Math.sin((Ang) * Math.PI / 180);<br />
}<br />
}</span></p>
<p>Set a new ball using the same actions we used for the &#8220;onLoad&#8221; above.</p>
<p>Code explanation for the paddle (much simpler than the ball&#8230;):</p>
<p style="padding-left: 30px;"><span style="color: #000080;">onClipEvent(enterFrame) {</span></p>
<p>On enterFrame, perform the action between the curly brackets.</p>
<p style="padding-left: 30px;">i<span style="color: #000080;">f(Key.isDown(Key.RIGHT)) {</span></p>
<p>If the right arrow key is pressed&#8230;.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if(this._x &lt;= 275) {</span></p>
<p>and the _x coordinate is less than 275 (the width of our stage minus 1/2 the width of our paddle)&#8230;</p>
<p style="padding-left: 30px;"><span style="color: #000080;">this._x += 10<br />
}<br />
}</span></p>
<p>move the paddle 10 pixels to the right.</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if(Key.isDown(Key.LEFT)) {</span></p>
<p>If the left arrow key is pressed&#8230;</p>
<p style="padding-left: 30px;"><span style="color: #000080;">if(this._x &gt;= 25) {</span></p>
<p>and the _x coordinate is greater than 25 (1/2 the width of our paddle)&#8230;</p>
<p style="padding-left: 30px;"><span style="color: #000080;">this._x -= 10;<br />
}<br />
}<br />
}</span></p>
<p>move the paddle 10 pixels to the left.</p>
<p>Since there is a lot going on with this, I decided to break this game tutorial into several parts. Check back soon for Part 2 which will explain how to set up the bricks which is really what turns this into a fun, interactive game.</p>
<p>Continue to <a title="Flash Game Tutorial part 2" href="http://mikestickney.com/wordpress/flash-tutorial-flash-game/" >Part 2 &gt;&gt;</a></p>
<p><strong>Source Files (Flash 8): </strong><a title="Flash Tutorial: Breakthru Flash Game Part 1" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/05/breakthru_game.fla" >Flash Tutorial: Breakthru Flash Game Part 1</a></p>
<p align="center"><script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
/* adunit-3 */
google_ad_slot = "2320139928";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-breakout-game-part-1/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Dynamic Buttons</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-dynamic-buttons/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-dynamic-buttons/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 21:02:26 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[actionscript tutorial]]></category>
		<category><![CDATA[dynamic buttons]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/?p=29</guid>
		<description><![CDATA[Flash Tutorial: Adding buttons dynamically to the Flash stage using ActionScript
Level: This is an intermeidate lesson, so I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with earlier [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Adding buttons dynamically to the Flash stage using ActionScript</p>
<p><strong>Level:</strong> This is an intermeidate lesson, so I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p style="text-align: left;"><strong>Description:</strong> In this tutorial, I will explain how to add buttons to your Flash movie with dynamic text content using ActionScript:</p>
<p><strong>Demo:</strong> 
<object type="application/x-shockwave-flash" width="250" height="100">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/dynamicButton_tutorial.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/dynamicButton_tutorial.swf" type="application/x-shockwave-flash" width="250" height="100" >
</object>
</p>
<p>Let&#8217;s get started!</p>
<p><strong>Note:</strong> For this tutorial, I will be using the buttons I created for a previous tutorial titled &#8220;Animating a button using a mask effect&#8221;.</p>
<p><span id="more-29"></span>If you haven&#8217;t already, I recommend you start with that tutorial, as I will not be going over the animation process of the button symbols in this tutorial. If you already know how to create button animations, you can use your own button animation symbol, or <a title="Flash Tutorial: Animated Button with Mask Effect" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/btnWithMask_tut1.fla" >download the previous tutorial source file here</a>.</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Select &#8220;File &gt; New&#8221; (command-&#8221;N&#8221;) and select Flash File (ActionScript 2.0) to open a new Flash document file. Save the file, and give it the appropriate name. I will call this &#8220;dynamicButton_tutorial.fla&#8221;. Feel free to change the document dimensions to whatever you like (&#8220;Modify &gt; Document or &#8220;command-J&#8221;), but for the purpose of this tutorial, I will use 250&#215;100 pixels.</p>
<p>Choose &#8220;File &gt; Import &gt; Open External Library&#8221; (shift-cmd-O), and navigate to where you placed the source file of our previous tutorial (btnWithMask_tut1.fla) and click &#8220;Open&#8221;. What this will do is open up just the &#8220;Symbol Library&#8221; of that source file. Tip: You can also access the symbol library of any .fla file you have open with the dropdown menu in your Symbol Library window (Fig. 1).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut10_fig1.gif" alt="Dynamic button tutorial fig. 1" width="450" height="455" /></p>
<p>We will be using the symbol called &#8220;mc_btn1&#8243; from the Button With Masked Animation source file, so we can simply click and drag this symbol from one library to the other. (Fig. 1). If you notice, when you drag the one symbol, it should also place the symbol &#8220;img_highlight&#8221; in your current file symbol library. This is because the &#8220;img_highlight&#8221; symbol is used within the &#8220;mc_btn1&#8243; symbol, so Flash knows to import all associated symbols as well.</p>
<p>You can go ahead and close the external symbol library so save space since we don&#8217;t need any other symbols from there. In our dynamic button .fla symbol library, double click on our &#8220;mc_btn1&#8243; symbol to bring us into symbol editing mode. You should see several layers and animation tweens in your timeline. We are going to leave all of this as is, so go ahead and lock all of these layers. What we need to do is add our text boxes that we will be using as our button labels. Add a new layer above your layer named &#8220;mask&#8221; and call it &#8220;text&#8221;. WIth the text tool (T), draw a box roughly the same width of our button, and position it on the center of our button shape. Select your text box, and in the Properties Panel (WIndow &gt; Properties &gt; Properties (cmd-F3)), and give it the settings in Fig. 2.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut9_fig2.gif" alt="Dynamic button tutorial fig. 2" width="350" height="85" /></p>
<p>Now, select the text box, choose Edit &gt; Copy (cmd-C) and then Edit &gt; Paste in Place (cmd-shift-V), and move it 2 or three pixels up and to the left. In Properties Panel, leave all the settings the same, except change the instance name from &#8220;textBlack&#8221; to &#8220;textWhite&#8221;, and change the color to white. What we are doing is simply giving our button label a basic &#8220;dropshadow&#8221; effect, just to make it more easily legible on all the button states.</p>
<p>We are now done editing our button, but since we are going to be placing our button on the stage using ActionsScript, the final thing we need to do is assign our buttona &#8220;Linkage&#8221; identifier name. Not to be confused with &#8220;symbol name&#8221; or &#8220;instance name&#8221;, an identifier name is used to call our button in ActionScript in order to be place on our stage. To give you button an id, right-click (control-click) on your button symbol in your library, and select &#8220;Linkage&#8230;&#8221; from the menu. This will open the Linkage Properties window (Fig. 3). Click on the &#8220;Export for ActionScript&#8221; check box and in the &#8220;Identifier&#8221; field, type &#8220;button&#8221; and hit OK.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut10_fig3.gif" alt="Dynamic button tutorial fig. 3" width="400" height="255" /></p>
<p>Now, it&#8217;s time for our ActionScript. It may look like a lot, but don&#8217;t be too intimidated, it&#8217;s not nearly as complicated as it looks, I promise!</p>
<p>On our main timeline, click on the first (and only) layer and give it a name of &#8220;actions&#8221;. In keyframe one, open the Actions Panel (Window &gt; Actions or alt-F9) and paste the following code:</p>
<p style="text-align: left; padding-left: 30px;"><span style="color: #000080;">onLoad = function(){<br />
var button:Array = [home, about, contact];</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">var xPosition:Number = 50;<br />
var yPosition:Number = 15;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">for(i=0;i&lt;button.length;i++){<br />
_root.attachMovie(&#8220;button&#8221;,&#8221;btn&#8221;+i,_root.getNextHighestDepth());</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">_root["btn"+i]._x = xPosition;<br />
_root["btn"+i]._y = yPosition;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">yPosition = yPosition + 25;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">_root.btn0.textBlack.text = &#8220;Home&#8221;;<br />
_root.btn1.textBlack.text = &#8220;About&#8221;;<br />
_root.btn2.textBlack.text = &#8220;Contact&#8221;;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">_root.btn0.textWhite.text = &#8220;Home&#8221;;<br />
_root.btn1.textWhite.text = &#8220;About&#8221;;<br />
_root.btn2.textWhite.text = &#8220;Contact&#8221;;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">_root.btn0.link = &#8220;http://www.spitshine-design.com&#8221;;<br />
_root.btn1.link = &#8220;http://www.spitshine-design.com/about.html&#8221;;<br />
_root.btn2.link = &#8220;http://www.spitshine-design.com/contact.html&#8221;;</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">_root["btn"+(i)].onRollOver = btnOver;<br />
_root["btn"+(i)].onRollOut = btnOut;<br />
_root["btn"+(i)].onRelease = btnRelease;<br />
_root["btn"+(i)].onPress = btnPress;<br />
}<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">function btnOver(){<br />
this.gotoAndPlay(&#8220;over&#8221;);<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">function btnOut(){<br />
this.gotoAndPlay(&#8220;off&#8221;);<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">function btnPress(){<br />
this.gotoAndStop(&#8220;down&#8221;);<br />
}</span></p>
<p style="padding-left: 30px;"><span style="color: #000080;">function btnRelease() {<br />
this.gotoAndStop(&#8220;off&#8221;);<br />
getURL(this.link);<br />
}</span></p>
<p style="text-align: left;">That&#8217;s it! Go ahead and test your movie. You should see 3 buttons appear, stacked, with the top one labled &#8220;home&#8221;, the middle one labeled &#8220;about&#8221; and the bottom one labeled &#8220;contact&#8221;. You should also see the animation on the different rollover states as well.</p>
<p>Since there is a lot of code here, rather than explain it all here, I decided to heavily comment the code in the source file. Since the real objective of any tutorial is for the reader to actually learn WHY things work and not just how, I encourage you to <a title="Flash Tutorial: Dynamic Buttons source file" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/dynamicButton_tutorial.fla" >download the source file</a> and read through the comments. The comments also help to explain the different items that need to be edited to customize your menu, such as placement, position and labels.</p>
<p>As always, I hope you found this tutorial helpful, and comments/questions are welcome. Thanks for reading!</p>
<p><strong>Source Files (Flash 8): </strong><a title="Flash Tutorial: Dynamic Buttons" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/dynamicButton_tutorial.fla" >Flash Tutorial: Character Movement with Arrow Keys</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-dynamic-buttons/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Character Movement with Arrow Keys</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-character-movement-with-arrow-keys/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-character-movement-with-arrow-keys/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 02:14:48 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[ActionsScript Tutorial]]></category>
		<category><![CDATA[arrow keys]]></category>
		<category><![CDATA[character movement]]></category>
		<category><![CDATA[design tutorial]]></category>
		<category><![CDATA[flash design; Movie Clip]]></category>
		<category><![CDATA[flash development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/flash-tutorial-character-movement-with-arrow-keys/</guid>
		<description><![CDATA[Level: This is a basic ActionsScript tutorial. As this is not an animation tutorial, a basic knowledge of the Flash user environment is assumed
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Level: </strong>This is a basic ActionsScript tutorial. As this is not an animation tutorial, a basic knowledge of the Flash user environment is assumed</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p><strong>Description:</strong> In this Flash tutorial, I will show you how to move a game character using the arrow keys, and have the character face in the direction that he is moving.</p>
<p><strong>Demo:</strong><br />

<object type="application/x-shockwave-flash" width="400" height="300">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/charMove_tut1.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/charMove_tut1.swf" type="application/x-shockwave-flash" width="400" height="300" >
</object>
</p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Select &#8220;File &gt; New&#8221; (command-&#8221;N&#8221;) and select Flash File (ActionScript 2.0) to open a new Flash document file.</p>
<p><span id="more-28"></span>Save the file, and give it the appropriate name. I will call this &#8220;charMove_tut1&#8243;. Feel free to make the document dimensions (&#8220;Modify &gt; Document or &#8220;command-J&#8221;) whatever you like, but I chose to use a size of 400 x 300 pixels.</p>
<p>The first thing we want to do is create a game character with 4 seperate states: left profile, right profile, front profile and back profile. Because this is not an illustration / animation tutorial, I will not be going through how to illustrate your character. Feel free to illustrate your own character, and convert each profile into it&#8217;s own symbol. For those beginners who do not want to illustrate their own character at this time, feel free to download the below .swf files (or jump to the source at the bottom of this page):</p>
<p>Front Profile: <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_front.swf" >Download</a> (right click on link and select &#8220;Save Link As&#8221;) 
<object type="application/x-shockwave-flash" width="50" height="95">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_front.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_front.swf" type="application/x-shockwave-flash" width="50" height="95" >
</object>
</p>
<p>Left Profile: <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_left.swf" >Download</a> 
<object type="application/x-shockwave-flash" width="50" height="95">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_left.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_left.swf" type="application/x-shockwave-flash" width="50" height="95" >
</object>
</p>
<p>Right Profile: <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_right.swf" >Download</a><br />

<object type="application/x-shockwave-flash" width="50" height="95">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_right.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_right.swf" type="application/x-shockwave-flash" width="50" height="95" >
</object>
</p>
<p>Back Profile: <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_back.swf" >Download</a><br />

<object type="application/x-shockwave-flash" width="50" height="95">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_back.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/ninja_back.swf" type="application/x-shockwave-flash" width="50" height="95" >
</object>
</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>To import these files, open your Flash file, select &#8220;File &gt; Import &gt; Import to Library&#8221;, browse to where you saved the above files, select the files and click the &#8220;Import to Library&#8221; button. You should now see the 4 profiles as symbols in your Flash document Library (Window &gt; Library (cmd-L)).</p>
<p>Once you have your character profiles ready (either by using mine or creating your own), we will need to place them in a movie clip symbol in order to control the movement. On frame 1 of our main movie timeline, select &#8220;Insert &gt; New Symbol&#8221; (cmd-F8). This will bring up the &#8220;Create New Symbol&#8221; dialog box (Fig. 1). In the &#8220;Name&#8221; field, give your symbol an appropriate name (I chose &#8220;mc_character&#8221;, select the &#8220;Movie Clip&#8221; radial, and hit OK. This will automatically put you in the symbol editing mode for your new symbol. In your new symbol, create 2 new layers. Name the top layer &#8220;actions&#8221;, the second layer &#8220;labels&#8221; and the bottom layer &#8220;character&#8221;.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut9_fig1.gif" alt="" /></p>
<p>Extend your timeline to 20 frames. Select keyframe 5 for all 3 layers (you can shift click or click and drag), and insert a new keyframe (Insert &gt; Timeline &gt; Keyframe or F6). Do the same thing at frame 10 and 15. Click on keyframe 1 of our &#8220;labels&#8221; layer, and in the Properties window (Window &gt; Properties &gt; Properties or cmd-F3), give this frame a label of &#8220;right&#8221; (Fig. 2).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut9_fig2.gif" alt="" width="350" height="85" /></p>
<p>On frame 5, do the same thing, giving it a lable of &#8220;left&#8221;, frame 10 label &#8220;up&#8221;, frame 20 label &#8220;down&#8221;. Your timeline should now look similar to Fig. 3.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut9_fig3.gif" alt="" width="386" height="220" /></p>
<p>Note: Technically, we can make this movie clip only 4 frames, with frames 1-4 labeled the same as above. However, For the purposes of this tutorial, I felt it better to extend the frames in order to better illustrate the frame labels.</p>
<p>On frame 1 of your &#8220;character&#8221; layer, drag your right profile symbol to the stage and align it to the center. Tip: You can center align your symbols to the stage by using the Align palette (Window &gt; Align or cmd-K (Fig. 4). Be sure the &#8220;To Stage&#8221; button is selected (it will be a darker shade of grey when selected) to align your sybols to the stage, deselecting this button allows you to align multiple symbols to each other.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut9_fig4.gif" alt="" width="219" height="170" /></p>
<p>On frame 5 of your &#8220;character&#8221; layer, drag your left profile symbol to the stage and align it to the center. In case you haven&#8217;t figured it out, do the same thing at frame 10 with the back profile symbol and frame 15 with the front profile symbol.</p>
<p>The last step is to add the ActionScript to our movie clip symbol. On the &#8220;actions&#8221; layer, click on frame 1, and add the following code to the Action panel (WIndow &gt; Actions or alt-F9):</p>
<blockquote><p><span style="color: #000080;">stop();</span></p></blockquote>
<p>This simply stops our movie from playing through, since we only want it to change based on what key is pressed. Do the same thing at frame 5, 10, and 15 of our &#8220;actions&#8221; layer.</p>
<p>Our movie clip is now complete, so it&#8217;s time to add the ActionScript that will control our movement and the profile of our character.</p>
<p>Return to your main timeline. Drag your &#8220;mc_character&#8221; symbol from the library onto your stage. WIth your character selected, add the following code to the Actions panel:</p>
<blockquote><p><span style="color: #000080;">onClipEvent(enterFrame){</span><br />
<span style="color: #000080;">if(Key.isDown(Key.RIGHT)){</span><br />
<span style="color: #000080;">this._x += 5;</span><br />
<span style="color: #000080;">this.gotoAndStop(&#8220;right&#8221;);</span><br />
<span style="color: #000080;">}</span></p>
<p><span style="color: #000080;">if(Key.isDown(Key.LEFT)){</span><br />
<span style="color: #000080;">this._x -= 5;</span><br />
<span style="color: #000080;">this.gotoAndStop(&#8220;left&#8221;);</span><br />
<span style="color: #000080;">}</span></p>
<p><span style="color: #000080;">if(Key.isDown(Key.UP)){</span><br />
<span style="color: #000080;">this._y -= 5;</span><br />
<span style="color: #000080;">this.gotoAndStop(&#8220;up&#8221;);</span><br />
<span style="color: #000080;">}</span></p>
<p><span style="color: #000080;">if(Key.isDown(Key.DOWN)){</span><br />
<span style="color: #000080;">this._y += 5;</span><br />
<span style="color: #000080;">this.gotoAndStop(&#8220;down&#8221;);</span><br />
<span style="color: #000080;">}</span></p>
<p><span style="color: #000080;">}</span></p></blockquote>
<p><strong>UPDATE</strong>: I’ve been finding several readers having trouble with doing a straight copy/paste of this code from the Web. I believe the issue lies in the quotation marks (”). When copying from the Web, it sometimes uses “smartquotes”. If you are getting an error on test regarding the quote marks, first step is to be sure you are using regular quotes (type them in instead of copy/paste from the Web site). If you are still having problems, feel free to drop me a comment and I will try my best to help resolve your issues. &#8211; Mike</p>
<p>That&#8217;s it! Go ahead and test your movie. What you shoud see is when you click on the arrow keys, your character not only moves in that direction, but faces that direction as well (up being backwards, down being forwards).</p>
<p>Now, let me try and explain the code:</p>
<blockquote><p><span style="color: #000080;">onClipEvent(enterFrame){</span></p></blockquote>
<p>On ClipEvent refers to the movie clip which this code is added to, the &#8220;enterFrame&#8221; is saying everytime our movie enters this frame of our main timeline, peform the actions between the curly brackets.</p>
<blockquote><p><span style="color: #000080;">if(Key.isDown(Key.RIGHT)){</span></p></blockquote>
<p>when the right arrow key is pressed, perform the actions within the curly brackets.</p>
<blockquote><p><span style="color: #000080;">this._x += 5;</span></p></blockquote>
<p><span style="color: #000080;">this.</span> refers to the movie clip that this code is attached to. <span style="color: #000080;">_x</span> refers to the x position of this movie clip. If the right arrow is pressed, move the moviclip 5 pixels to the right (Tip: for faster movement, increase this number, for slower movement, decrease this number).</p>
<blockquote><p><span style="color: #000080;">this.gotoAndStop(&#8220;right&#8221;);</span><br />
<span style="color: #000080;">}</span></p></blockquote>
<p>Go to our frame labeled &#8220;right&#8221; in our movie clip symbol and stop on that frame. (Tip: Frame labels are case sensitive).</p>
<blockquote><p><span style="color: #000080;">if(Key.isDown(Key.LEFT)){</span><br />
<span style="color: #000080;">this._x -= 5;</span><br />
<span style="color: #000080;">this.gotoAndStop(&#8220;left&#8221;);</span><br />
<span style="color: #000080;">}</span></p></blockquote>
<p>This code is doing the same as above, but saying if the left arrow is pressed, move the clip 5 pixels to the left and go to our frame labeled &#8220;left&#8221;.</p>
<blockquote><p><span style="color: #000080;">if(Key.isDown(Key.UP)){</span><br />
<span style="color: #000080;">this._y -= 5;</span><br />
<span style="color: #000080;">this.gotoAndStop(&#8220;up&#8221;);</span><br />
<span style="color: #000080;">}</span></p></blockquote>
<p>This is doing the same as above, but saying if the up arrow is pressed, move the clip 5 pixels up (<span style="color: #000080;">_y</span> represents the y position of your clip) and go to our frame labeled &#8220;up&#8221;.</p>
<blockquote><p><span style="color: #000080;">if(Key.isDown(Key.DOWN)){</span><br />
<span style="color: #000080;">this._y += 5;</span><br />
<span style="color: #000080;">this.gotoAndStop(&#8220;down&#8221;);</span><br />
<span style="color: #000080;">} </span><br />
<span style="color: #000080;">}</span></p></blockquote>
<p>This is doing the same as above, but saying if the down arrow is pressed, move the clip 5 pixels down and to go our frame labeled &#8220;down&#8221;.</p>
<p>Thanks for reading, and I hope you found this tutorial useful. Source files are below, with commented code. As always, comments or questions are welcome. Check back soon for more expaned tutorials based on the idea of character movement.</p>
<p><strong>Source Files (Flash 8): </strong><a title="Flash Tutorial: Character Movement with Arrow Keys" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/04/charMove_tut1.fla" >Flash Tutorial: Character Movement with Arrow Keys</a><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-character-movement-with-arrow-keys/feed/</wfw:commentRss>
		<slash:comments>90</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Quick and Easy Zoom Effect on Mouse Over</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-quick-and-easy-zoom-effect-on-mouse-over/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-quick-and-easy-zoom-effect-on-mouse-over/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 00:57:25 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/flash-tutorial-quick-and-easy-zoom-effect-on-mouse-over/</guid>
		<description><![CDATA[Flash Tutorial: Quick and Easy Zoom Effect on Mouse Over
Level: This is a beginner level tutorial, but knowledge of the Flash drawing tools is assumed.
Version: I will be using Flash CS3 and AS2 (although tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Quick and Easy Zoom Effect on Mouse Over</p>
<p><strong>Level:</strong> This is a beginner level tutorial, but knowledge of the Flash drawing tools is assumed.</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (although tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p><strong>Description:</strong> In this tutorial, I will demonstrate a quick and easy zoom in/out technique using a motion tween and a little ActionScript.</p>
<p><strong>Demo:</strong> 
<object type="application/x-shockwave-flash" width="350" height="200">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/zoom_tut1.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/zoom_tut1.swf" type="application/x-shockwave-flash" width="350" height="200" >
</object>
</p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Select &#8220;File &gt; New&#8221; (command-&#8221;N&#8221;) and select Flash File (ActionScript 2.0) to open a new Flash document file.</p>
<p><span id="more-27"></span>Save the file, and give it an appropriate name. I will call this &#8220;zoom_tut1.fla&#8221;. Feel free to change the document dimensions to whatever you like (&#8220;Modify &gt; Document or &#8220;command-J&#8221;), but for the purpose of this tutorial, I will use 350&#215;200 pixels.</p>
<p>The first thing we need to do is draw the object that we want to have zoom in and out. You can have this be whatever you like, but I will just use a simple rectangle with some text inside it. To do this, select the rectangle tool, give a fill color (whatever you like, it doesn&#8217;t matter), and a stroke if you desire (I chose a black fill with no stroke). Draw a small rectangle on the center of your stage. With the selection tool, select your rectangle (click-drag around your shape or double click on the shape) and choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8). Give your symbol an appropriate name (I called mine &#8220;box&#8221;), select the Movie Clip radial and hit &#8220;OK&#8221;. Your rectangle is now a movie clip symbol and should be available in your Library window (Window &gt; Library or cmd-L).</p>
<p>Double click on your symbol (either on the stage or in your Library) to bring you into symbol editing mode. Within your movie clip symbol, select your rectangle and choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8) again, however this time choose the Graphic radial and give this symbol a new name (I chose &#8220;img_box&#8221;) and hit &#8220;OK&#8221;. We now have a &#8220;nested&#8221; symbol&#8230; a graphic symbol that is within our movie clip symbol. Now, click on your rectangle to bring you into editing mode for the graphic symbol. <strong>Tip:</strong> you will see a &#8220;breadcrumb&#8221; of what symbol your are currently in mode under your timeline (Fig. 1).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut8_fig1.gif" height="230" width="389" /></p>
<p>Add a new layer to your graphic symbol and with the Text tool, draw a box in the center of your rectangle and type &#8220;Zoom&#8221; (or whatever you like). While you don&#8217;t really need text for this symbol, I wanted to try and illustrate that this tutorial will work whether your object is on one layer, or if you have a symbol with multiple layers.</p>
<p>We now need to edit our movie clip symbol, so you can either double click on the symbol in your Library, or use the &#8220;breadcrumb&#8221; link under the timeline (Fig. 1). <strong>Tip:</strong> you will only see the breadcrumb of a nested symbol if you select your symbol by double clicking the object on your stage. If you select your symbol in the Library, you will only see the name of the symbol you selected. It is important to remember that whether you select the symbol directly from your library or by clicking on it&#8217;s instance on the stage, you are editing ALL instances of the symbol.</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>In our movie clip symbol, click on frame 15 and choose &#8220;Insert &gt; Timeline &gt; Keyframe&#8221; (F6). On frame 15, select your rectangle (clicking only once) and scale the symbol to about 300% (or the maximum size you want your object to be able to zoom). <strong>Tip:</strong> to easily scale an object use the &#8220;Transform&#8221; pallette (Window &gt; Transform or cmd-T) and input a number (Fig. 2).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut8_fig2.gif" alt="Flash tutorial image 2" height="170" width="219" /></p>
<p>Still in our movie clip symbol, click on a frame between 1 and 15 in our timeline and choose &#8220;Insert &gt; Timeline &gt; Create Motion Tween&#8221;. The color of the timeline on this layer should turn a light blue and you will see a solid arrow between frames 1 and 15 (Fig. 3). What we now have is an animation of a rectangle that goes from small to large. Now, we need to add some simple ActionScript that will control the zoom effect.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut8_fig3.gif" alt="Flash Tutorial image 3" height="230" width="382" /></p>
<p>Let&#8217;s start by adding a new layer to our movie clip symbol. Move this layer to the top and name it &#8220;actions&#8221;. On frame 1, add the following code to our Actions Panel (Windows &gt; Actions or alt-F9):</p>
<blockquote><p><font color="#000080">stop();</font></p>
<p><font color="#000080">this.onEnterFrame = function(){<br />
if(zoom == true){<br />
prevFrame();<br />
}<br />
}</font></p>
<p><font color="#000080">this.onRollOver = function(){<br />
zoom = false;<br />
play();<br />
}</font></p>
<p><font color="#000080">this.onRollOut = function(){<br />
zoom = true;<br />
}</font></p></blockquote>
<p>On frame 15 of our &#8220;actions&#8221; layer, add the following code to the Actions Panel:</p>
<blockquote><p><font color="#000080">stop();</font></p></blockquote>
<p>One last thing we want to do is change the frame rate (fps) in order to give our zoom a smoother animation. To do this, choose &#8220;Modify &gt; Document&#8221; or cmd-J to open the document properties window, and change the number in the &#8220;Frame Rate&#8221; field (Fig. 4).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut8_fig4.gif" alt="Flash tutorial image 4" height="330" width="350" /></p>
<p>The default rate of Flash is 12, and the most common rates are 12, 24 or 30 with 30 being probably the fastest you would want to make it. For this tutorial, I have chosen to use 30 fps. <strong>Tip:</strong> &#8220;fps&#8221; stands for &#8220;frames per second&#8221;, thus changing the frame rate will also change the speed of your animation (your zoom effect). The higher the frame rate, the faster your animation. 12 fps works well for the web, especially if there is a lot of animation. Since this was a simple animation, we can get a nice smooth zoom by upping the fps to 30. We could also control the smoothness of our animation by adding or subtracting the number of frames in our movie clip timeline. The important thing to do is to find a nice balance of frame rate and length of timeline, and in most cases this is  done simply by testing your movie. However, it is my recommendation to not tweak the fps once your movie is built but to add or subtract frames from your timeline.</p>
<p>That&#8217;s it! Go ahead and test your movie. Place your mouse over the rectangle, and you should see your object zoom in&#8230; move your mouse off the object and it will zoom out and return back to the original size.</p>
<p>Now my favorite part – explaining the code!</p>
<blockquote><p><font color="#000080">stop();</font></p></blockquote>
<p>This is a simple stop action that tells our movie clip to stop playing since we want to control the animation with our mouse.</p>
<blockquote><p><font color="#000080">this.onEnterFrame = function(){</font></p></blockquote>
<p>This is saying everytime our player enters the frame, perform the actions between the curly brackets. Note: &#8220;<font color="#000080">this.</font>&#8221; refers to the movie clip that this action is placed in. It is optional, but good practice to use it.</p>
<blockquote><p><font color="#000080">if(zoom == true){<br />
prevFrame();<br />
}<br />
}</font></p></blockquote>
<p>The &#8220;<font color="#000080">if</font>&#8221; statement is asking if a variable of &#8220;<font color="#000080">zoom</font>&#8221; is true, and if it is, then perform the actions between the curly brackets.</p>
<blockquote><p><font color="#000080">this.onRollOver = function(){<br />
zoom = false;<br />
play();<br />
}</font></p></blockquote>
<p>This is saying when we roll over our object (remember &#8220;<font color="#000080">this.</font>&#8221; is referring to the movie clip this script is in) perform the actions between the curly brackets. The actions are telling the player that &#8220;<font color="#000080">zoom</font>&#8221; is equal to &#8220;<font color="#000080">false</font>&#8220;, which means we are not performing the &#8220;<font color="#000080">if</font>&#8221; statement above, but so we will &#8220;<font color="#000080">play</font>&#8221; our movie (zooming in).</p>
<blockquote><p><font color="#000080">this.onRollOut = function(){<br />
zoom = true;<br />
}</font></p></blockquote>
<p>This is telling the Flash player that when we roll off our object, our &#8220;<font color="#000080">zoom</font>&#8221; is equal to &#8220;<font color="#000080">true</font>&#8220;, so we will perform the if statement above which is telling the player to go to the previous frame and basically rewinding our timeline (zooming out).</p>
<p>While the same type of zooming effects can be created using just ActionScript rather than motion tweens (which I hope to show in a future tutorial), I hope you find that this is a very quick and simple way to create a zoom effect in Flash. And if you&#8217;re creative and understand the code, you can use this to control any type of animation, not just a zoom in/out.</p>
<p>I hope you enjoyed this <a href="http://mikestickney.com/wordpress/category/flash-tutorial/" >Flash tutorial</a> and thanks for reading. As always, feel free to leave comments below.</p>
<p><strong>Source file (Flash 8):</strong> <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/zoom_tut1.fla" title="Flash Tutorial: Quick and Easy Zoom Effect on Mouse Over">Flash Tutorial: Quick and Easy Zoom effect on Mouse Over<br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-quick-and-easy-zoom-effect-on-mouse-over/feed/</wfw:commentRss>
		<slash:comments>119</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Animating a button using a mask effect</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-animating-a-button-using-a-mask-effect/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-animating-a-button-using-a-mask-effect/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 01:33:12 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[ActionScript tutorials]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Tutorial]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/flash-tutorial-animating-a-button-using-a-mask-effect/</guid>
		<description><![CDATA[Flash Tutorial: Animating a button using a mask effect
Level: This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc..
Version: I will be using Flash CS3 and AS2 (although tut is compatible with earlier versions of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Animating a button using a mask effect</p>
<p><strong>Level: </strong>This is a beginner lesson, but I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc..</p>
<p><strong>Version:</strong> I will be using Flash CS3 and AS2 (although tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.</p>
<p><strong>Description:</strong> In this tutorial, I will explain how to give a button animation on rollover by creating a button as a movie clip symbol and using a mask effect.</p>
<p><strong>Demo:</strong> 
<object type="application/x-shockwave-flash" width="250" height="100">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/btnWithMask_tut1.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/btnWithMask_tut1.swf" type="application/x-shockwave-flash" width="250" height="100" >
</object>
</p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Select &#8220;File &gt; New&#8221; (command-&#8221;N&#8221;) and select Flash File (ActionScript 2.0) to open a new Flash document file. <span id="more-26"></span>Save the file, and give it the appropriate name. I will call this &#8220;btnWIthMask_tut1.fla&#8221;. Feel free to change the document dimensions to whatever you like (&#8220;Modify &gt; Document or &#8220;command-J&#8221;), but for the purpose of this tutorial, I will use 250&#215;100 pixels.</p>
<p>The first thing we will need to do is draw a simple shape for our button. Select the rectangle tool, set your fill color to the black and white linear gradient and a stroke of none. In the property window (Window &gt; Properties &gt; Properties or command-F3), set the corners to slightly rounded, I chose a 5 pixel rounded corner. Draw out a rectangle approximately 100&#215;20 pixels. <strong>Tip:</strong> You can use the up or down arrows on your keyboard when dragging out your rectangle shape to increase or decrease the roundness of your corners. You should have a rectangle similar to Fig. 1.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig1.gif" alt="" width="200" height="70" /></p>
<p>Select the rectangle, and convert to a movie clip symbol (Modify &gt; Convert to Symbol or F8). Remember, we are creating a movie clip button, so be sure to select the &#8220;movie clip&#8221; radial. Give your symbol an appropriate name, I called mine &#8220;mc_btn1&#8243;. Double click on your rectangle to bring you into the symbol editing mode. Select your rectangle and let&#8217;s adjust the gradient and on our button with the &#8220;Gradient Transform&#8221; tool. <strong>Tip:</strong> the Gradient Transform tool is grouped with the Free Transform tool in the tools pallette. With the Gradient tool selected, click on your rectangle and in the color pallete, set your gradient scale to be 100% black on one end and 100% dark grey (#666666) on the other. With the rectangle still selected, rotate your linear gradient to be vertical (<strong>Tip:</strong> Hold shift when rotating to snap to 45º angles), with the 100% black on the top and the grey on the bottom. Also, shrink the gradient tool so that it is the height of your rectangle. Fig. 2 shows what your rectangle should look like with the gradient tool selected.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig2.gif" alt="" width="200" height="70" /></p>
<p>Let&#8217;s add a little additional styling to our button by going to our tool palette and choosing the Selection Tool (V), selecting our entire rectangle, choose &#8220;Edit &gt; Copy&#8221; (cmd-C), add a new layer and choose &#8220;Edit &gt; Paste in Place&#8221; (shift-cmd-V) to paste a new rectangle on top of our original. Now, select the new rectangle, rotate it 180º and cut the height in half (about 10 pixels). <strong>Tip:</strong> You can adjust the height of your rectangle using the Info pallette (&#8220;Window &gt; Info&#8221; or cmd-I) and inputting the &#8220;H&#8221; field. Lastly, move the smaller rectangle so it aligns with the top of your original. You should now have a shape that looks similar to Fig. 3. This will be the base of our button.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig3.gif" alt="" width="200" height="70" /></p>
<p>For our animation, we will just do a simple &#8220;highlight&#8221; effect when the user rolls over the button. Before we start doing the animation, let&#8217;s set up our timeline. Let&#8217;s start by labeling our rectangle layers&#8230; the bottom one we can label &#8220;lower button&#8221;, the top one &#8220;upper button&#8221;. Now, add 4 new layers above these. The top one should be labeled &#8220;actions&#8221;, the second layer &#8220;labels&#8221;, the third one &#8220;mask&#8221; and the 4th &#8220;highlight&#8221;. Extend the keyframes for all layers to frame 30 by selecting Frame 30 on all layers and choosing &#8220;Insert &gt; Timeline &gt; Frame&#8221; (F5). On the &#8220;labels&#8221; layer, insert a new key frame (&#8220;Insert &gt; Timeline &gt; Keyframe&#8221; or F6) at frame 10 and 21. Select frame 1 of your labels layer, and in the Properties panel (&#8220;Window &gt; Property &gt; Properties&#8221; or cmd-F3), give your frame a label of &#8220;off&#8221;. Next label frame 10 &#8220;over&#8221; and frame 21 &#8220;down&#8221;. Finally, on the &#8220;actions&#8221; layer, let&#8217;s add a new keyframe at frame 20 and on our last frame. On frame 1 of our actions layer, add the following code to our Actions panel (&#8220;Window &gt; Actions&#8221; or alt-F9):</p>
<p>stop();</p>
<p>Do the same thing on frame 20 and the last frame of our &#8220;actions&#8221; layer. All this code does is stop our movie clip from playing on these particular frames, since for our end result we want the users mouse to control our timeline. Your symbol timeline should now look similar to Fig. 4.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig4.gif" alt="" width="300" height="150" /></p>
<p>Now that our timeline is set, let&#8217;s build our animation. Let&#8217;s lock all our layers, except the one labeled &#8220;highlight&#8221;. On our &#8220;highlight&#8221; layer, insert a new keyframe at frame 10. Select our rectangle tool, with a fill of linear gradient and a stroke of none. Draw a rectangle on the stage with a height of about 40 and a width of about 20. With our new rectangle still selected, use the gradient transform tool and set the gradient as left side 0% white, center 30% white and right side 0% white. (Fig. 5). Choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8) and make your new rectangle into a &#8220;graphic&#8221; and give it an appropriate name. With your rectangle symbol selected, rotate your rectangle and move it just off the top left corner of your button. Finally scale your rectangle to about 50%. When your rectangle is selected with the transform tool, it should look similar to Fig. 6.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig5.gif" alt="" width="200" height="300" /></p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig6.gif" alt="" width="200" height="74" /></p>
<p>Next, add a new keyframe to frame 20 of our highlight layer. On frame 20, move your rectangle to the bottom right corner of your button (Fig. 7). Click on your timeline anywhere between frame 10 and 20, choose &#8220;Insert &gt; Timeline &gt; Create Motion Tween&#8221;. Finally, add a new keyframe at frame 15, select our rectangle symbol (it should be about 1/2 way across your button), and scale it to about 200%. This will now be our button animation. What about the &#8220;mask&#8221; layer we made? Well, I&#8217;ll get to that shortly, but let&#8217;s make our menu and set our ActionScript so you can see why we will need a &#8220;mask&#8221; layer.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig7.gif" alt="" width="200" height="67" /></p>
<p>Return to the main timeline (Scene 1). Let&#8217;s add 2 new layers and label the top layer &#8220;actions&#8221;, the second layer &#8220;text&#8221; and the bottom layer &#8220;buttons&#8221; (with our &#8220;mc_btn1&#8243; symbol on the &#8220;buttons&#8221; layer). Next, add 2 more instances of our &#8220;mc_btn1&#8243; symbol to our &#8220;buttons&#8221; layer, and postion all 3 button symbols so they are left aligned and stacked (Fig. 8). Click on the top button, and in our Properties panel, give it an instance name of &#8220;btn_home&#8221;. Give the second button an instance name of &#8220;btn_about&#8221; and the bottom button and instance name of &#8220;btn_contact&#8221;.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig8.gif" alt="" width="191" height="155" /></p>
<p>On the &#8220;text&#8221; layer, draw a text box over the top button and type the word &#8220;Home&#8221;. On the second button, draw a text box and type the word &#8220;About&#8221;, and on the bottom button, draw a box and type the word &#8220;Contact&#8221; (Fig. 9).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut7_fig9.gif" alt="" width="185" height="150" /></p>
<p>Our buttons are now ready to have the ActionScript added for the mouse events. There are multiple ways of adding this script, and I have written a previous tutorial about <a href="http://mikestickney.com/wordpress/flash-tutorial-button-using-movie-clip-symbol/" >creating buttons with movieclips</a> where the actions are applied directly to the button. For this tutorial, I&#8217;ll show you another way, which is by adding the actions to the &#8220;actions&#8221; layer of our main timeline. Either way is suitable and there are advantages to both, so what I suggest is you experiment with both ways and decide for yourself what you like better.</p>
<p align="center">&#8212;- ads by google &#8212;-<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7252304256657784";
google_ad_slot = "4730110072";
google_ad_width = 234;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>On frame 1 of the &#8220;actions&#8221; layer of our main timeline, add the following code to the Action panel:</p>
<blockquote><p><span style="color: #000080;">btn_home.onRollOver = function() {<br />
_root.btn_home.gotoAndPlay(&#8220;over&#8221;);<br />
}<br />
btn_home.onPress = function() {<br />
_root.btn_home.gotoAndPlay(&#8220;down&#8221;);<br />
}<br />
btn_home.onRollOut = function() {<br />
_root.btn_home.gotoAndStop(&#8220;off&#8221;);<br />
}<br />
btn_home.onRelease = function() {<br />
_root.btn_home.gotoAndStop(&#8220;off&#8221;);<br />
}</span></p>
<p><span style="color: #000080;">btn_about.onRollOver = function() {<br />
_root.btn_about.gotoAndPlay(&#8220;over&#8221;);<br />
}<br />
btn_about.onPress = function() {<br />
_root.btn_about.gotoAndPlay(&#8220;down&#8221;);<br />
}<br />
btn_about.onRollOut = function() {<br />
_root.btn_about.gotoAndStop(&#8220;off&#8221;);<br />
}<br />
btn_about.onRelease = function() {<br />
_root.btn_about.gotoAndStop(&#8220;off&#8221;);<br />
}</span></p>
<p><span style="color: #000080;">btn_contact.onRollOver = function() {<br />
_root.btn_contact.gotoAndPlay(&#8220;over&#8221;);<br />
}<br />
btn_contact.onPress = function() {<br />
_root.btn_contact.gotoAndPlay(&#8220;down&#8221;);<br />
}<br />
btn_contact.onRollOut = function() {<br />
_root.btn_contact.gotoAndStop(&#8220;off&#8221;);<br />
}<br />
btn_contact.onRelease = function() {<br />
_root.btn_contact.gotoAndStop(&#8220;off&#8221;); </span><strong></strong></p></blockquote>
<p><strong>UPDATE</strong>: I’ve been finding several readers having trouble with doing a straight copy/paste of this code from the Web. I believe the issue lies in the quotation marks (”). When copying from the Web, it sometimes uses “smartquotes”. If you are getting an error on test regarding the quote marks, first step is to be sure you are using regular quotes (type them in instead of copy/paste from the Web site). If you are still having problems, feel free to drop me a comment and I will try my best to help resolve your issues. &#8211; Mike</p>
<p>Let me try to explain the code:</p>
<p>What we are doing is setting up some functions to control the timeline of each button. For instance:</p>
<blockquote><p><span style="color: #000080;">btn_home.onRollOver = function() {</span></p></blockquote>
<p>is saying &#8220;whenever the users mouse rolls over the &#8220;btn_home&#8221;, perform the actions between the curly brackets&#8221;.</p>
<blockquote><p><span style="color: #000080;">_root.btn_home.gotoAndPlay(&#8220;over&#8221;);<br />
}</span></p></blockquote>
<p>This is saying &#8220;play our &#8220;btn_home&#8221; timeline starting at the frame labeled &#8220;over&#8221;"</p>
<p>Hopefully from that explanation, you can figure out that the rest of the code is setting up the different actions (play or stop) for the different mouse events (onRollOver, onPress, onRelease and onRollOut) for the different buttons (btn_home, btn_contact and btn_about).</p>
<p>When you test your movie, you should have something that looks similar to this:</p>
<p>
<object type="application/x-shockwave-flash" width="250" height="100">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/btnWithMask_tut1_stage1.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/btnWithMask_tut1_stage1.swf" type="application/x-shockwave-flash" width="250" height="100" >
</object>
</p>
<p>Looks pretty good, except one problem&#8230; when we rollover the second and third buttons, we see our animation spill over onto the buttons above. What do we do now? Well, remember that &#8220;mask&#8221; layer we created in our button movieclip? That&#8217;s how!</p>
<p>I&#8217;ve written a previous tutorial on <a href="http://mikestickney.com/wordpress/flash-tutorial-working-with-masks-in-flash/" >working with masks in Flash</a> that gets a little more in-depth about creating masks, so I will only go through it quickly here, but you should get the jist of it. Of course I suggest you check out my <a href="http://mikestickney.com/wordpress/flash-tutorial-working-with-masks-in-flash/" >working with masks tutorial</a> if you would like more information.</p>
<p>Returning back to our .fla file, double click on any of our button symbols to bring us into the symbol editing mode. On our &#8220;lower button&#8221; layer, select the rectangle and choose &#8220;Edit &gt; Copy&#8221; (cmd-C). Click on frame 1 of our &#8220;mask&#8221; layer and choose &#8220;Edit &gt; Paste in Place&#8221; (shift-cmd-V) to place our rectangle on the stage. Again on our &#8220;mask&#8221; layer, double click on the icon next to the layer name to bring up our Layer Properties window. In our Layer Properties, click on the &#8220;Mask&#8221; radial button. Now on our &#8220;highlight&#8221; layer, open the Layer Properties window and select the &#8220;Masked&#8221; radial. (Again, for further explanation on working with masks, please refer to <a href="http://mikestickney.com/wordpress/flash-tutorial-working-with-masks-in-flash/" >this tutorial</a>).</p>
<p>That&#8217;s it! Our menu is done. Now when you test your movie, you should see the highlight animation on only the button your mouse rolls over.</p>
<p>I hope you enjoyed this tutorial and as always, comments are welcome. Thanks for reading!</p>
<p>Source Files (Flash 8): <a title="Flash Tutorial: Play movie clip on mouse click" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/btnWithMask_tut1.fla" >Flash Tutorial: Button with Mask Animation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-animating-a-button-using-a-mask-effect/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>
