<?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 development</title>
	<atom:link href="http://mikestickney.com/wordpress/tag/flash-development/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>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: Play a movie clip a set number of times and then stop</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-play-a-movie-clip-a-set-number-of-times-and-then-stop/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-play-a-movie-clip-a-set-number-of-times-and-then-stop/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 18:57:51 +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[design tutorial]]></category>
		<category><![CDATA[flash design; Movie Clip]]></category>
		<category><![CDATA[flash development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/flash-tutorial-play-a-movie-clip-a-set-number-of-times-and-then-stop/</guid>
		<description><![CDATA[Flash Tutorial: Stop a movie clip after playing 3 times
Level: This is an intermediate lesson, that focuses on the ActionScript involved. It is assumed the user has basic Flash knowledge that includes creating symbols, creating motion tweens and creating frame lables.
Version: I will be using Flash CS3 and AS2 (athough tut is compatible with earlier [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash Tutorial:</strong> Stop a movie clip after playing 3 times</p>
<p><strong>Level:</strong> This is an intermediate lesson, that focuses on the ActionScript involved. It is assumed the user has basic Flash knowledge that includes creating symbols, creating motion tweens and creating frame lables.</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 demonstrate and explain the ActionScript involved to play a movie clip a certain number of times, and then stop playing. This tutorial focuse on the AS, so some basic Flash animation knowledge is assumed.</p>
<p><strong>Demo: </strong>
<object type="application/x-shockwave-flash" width="400" height="200">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/playClip3Times.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/playClip3Times.swf" type="application/x-shockwave-flash" width="400" 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. Save the file, and give it the appropriate name.<span id="more-21"></span>I will call this &#8220;clipDemo_tut1.fla&#8221;. Feel free to make the document dimensions whatever you like (&#8220;Modify &gt; Document or &#8220;command-J&#8221;), but I chose to use a size of 400 x 200 pixels. Create 3 layers and label the top one &#8220;actions&#8221; the second one &#8220;counter&#8221; and the bottom one &#8220;ball&#8221;.</p>
<p>The first thing we need to do is create a simple animation. For this tutorial, I simply created a circle that will move horizontally across the stage. I will assume the reader of this tutorial has some knowledge of creating a movie clip in Flash, so I will just walk through this quickly without much detailed instuction.</p>
<p align="center"><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>First, on the &#8220;ball&#8221; layer, draw a circle on the stage, and position against the left side. Select the cirlce and choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8), give the symbol a name (I will use &#8220;mc_ball&#8221;) and choose the Movie Clip radial. Double click on the new symbol (either on the stage or in the Library), to bring you into editing mode. Click on the circle again to select it, and again choose &#8220;Modify &gt; Convert to Symbol&#8221; (F8), give your symbol a new name (I will use &#8220;img_ball&#8221;), and this time select the &#8220;Graphic&#8221; radial. Going back to your movie clip, add some frames to your timeline, however many you want, it doesn&#8217;t matter, I will make mine 35 frames long. Add a new keyframe to the layer with your circle. On the last frame of your movie, move the circle off to the right side of your stage. Select any frame between 1 and 35 and select &#8220;Insert &gt; Timeline &gt; Create Motion Tween&#8221;. You should now have a simple animation of the ball sliding across your stage.</p>
<p>
<object type="application/x-shockwave-flash" width="400" height="200">
<param name="movie" value="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/stage1.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/stage1.swf" type="application/x-shockwave-flash" width="400" height="200" >
</object>
</p>
<p>This is the animation we will use for this demonstration. Now it&#8217;s time to focus in on the purpose of this article, which is the ActionScript involved to make this movieclip play a certain number of times (3), and then stop.</p>
<p>In our &#8220;mc_ball&#8221; movie clip, add 2 layers to the timeline label the top one &#8220;actions&#8221; and the second one &#8220;labels&#8221;, and add a keyframe to the last frame of each layer. On frame 1 of the &#8220;labels&#8221; layer, in your property window, give this a frame label of &#8220;begin&#8221;, and on the last frame, give it a label of &#8220;end&#8221;. On the last frame of he &#8220;actions&#8221; layer, insert the following code in the actions panel (Windows &gt; Actions or alt-F9):</p>
<blockquote><p><font color="#000080">_root.counter += 1;</font></p>
<p><font color="#000080">if (_root.counter &gt;= 3) {<br />
_root.mc_ball.stop();<br />
}</font></p>
<p><font color="#000080">else {<br />
_root.mc_ball.gotoAndPlay(&#8220;begin&#8221;);<br />
}</font></p></blockquote>
<p>Don&#8217;t worry, I will explain the code later. For now, let&#8217;s continue with the tutorial.</p>
<p>Return to the main timeline (scene 1). Click on the cirlce movie clip on the stage and in the properties window, give this an instance name of &#8220;mc_ball&#8221;.</p>
<p>Still in our main timeline, on frame 1 of the &#8220;actions&#8221; layer, add the following code:</p>
<blockquote><p><font color="#000080">var counter = 0</font></p>
<p><font color="#000080">stop();</font></p></blockquote>
<p>Technically, we are now done with our movie. Go ahead and test it out&#8230; you should see the circle travel across the stage 3 times, and then stop (stop being a blank stage). However, let&#8217;s add some additional ActionScript to better demonstrate what the code is doing. The following instructions are optional and are used simply to better illustrate what is happening.</p>
<p>First thing we want to do is tell us how many times the movie clip played, so for that I will add a simple counter in the lower corner. In scene 1, on the &#8220;counter&#8221; layer that we created earlier, let&#8217;s just put a text box in the lower corner and type the word &#8220;counter&#8221;. Next to this text, with the &#8220;text tool&#8221;, draw a small text box, and in the properties manual, set the text type to &#8220;Dynamic&#8221; and in the &#8220;Var&#8221; field, type &#8220;counter&#8221;. Let&#8217;s also give it an instance name of &#8220;counter&#8221; (Fig. 1).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut4_fig1.gif" alt="Tutorial 4: Figure 1" height="85" width="400" /></p>
<p>Now, if we test our movie again, you should see a display of the number of times the animation has played in the bottom corner of the stage. The last thing we want to do is place a &#8220;replay&#8221; button on the so we can see the demonstration again.</p>
<p align="center"><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>Let&#8217;s add a new layer to our timeline and call it &#8220;Replay&#8221;. Below the &#8220;counter&#8221; text on the stage, let&#8217;s draw a text box and type the words &#8220;Demonstrate Again&#8221;. Note: be sure to change the &#8220;Text type&#8221; in our properties window back to &#8220;static&#8221;. Click on the text, select &#8220;Modify &gt; Convert to Symbol&#8221; (F8), and give this a name of &#8220;mc_reset&#8221; and be sure to select the &#8220;movie clip&#8221; radial. With our new symbol selected, let&#8217;s give this an instance name of &#8220;mc_reset&#8221;, and add the following code to the Actions Panel:</p>
<blockquote><p><font color="#000080">on (release) {<br />
_root.counter -= 3;<br />
_root.mc_ball.gotoAndPlay(&#8220;begin&#8221;);<br />
this.gotoAndPlay(&#8220;begin&#8221;);<br />
}</font></p></blockquote>
<p>Now, double click on the mc_reset symbol to bring us into the symbol editing mode and add 2 new layers, one named &#8220;actions&#8221; and one named &#8220;labels&#8221;. Let&#8217;s also add a new frame to all three layers. In the &#8220;actions&#8221; layer, add the following code to the Actions Panel on both frames:</p>
<blockquote><p><font color="#000080">stop();</font></p></blockquote>
<p>Now, in the &#8220;labels&#8221; layer, let&#8217;s label frame 1 &#8220;begin&#8221; and frame 2 end&#8221;. Lastly, let&#8217;s delete the content from frame 1 of our text layer so that we only see the &#8220;demonstrate again&#8221; on the seconcd frame.</p>
<p>Still with me? Don&#8217;t worry, we are almost done&#8230;</p>
<p>Go to your &#8220;mc_ball&#8221; symbol, and on the last frame in the &#8220;actions&#8221; layer in the Actions Panel, add the code in blue below to the existing code (the code in green is what was added previously:</p>
<blockquote>
<blockquote></blockquote>
<p><font color="#008000">_root.counter += 1;</font></p>
<p><font color="#000080"><font color="#008000">if (_root.counter &gt;= 3) {<br />
_root.mc_ball.stop();</font><br />
_root.mc_reset.gotoAndStop(&#8220;end&#8221;);</font><font color="#000080"><br />
<font color="#008000">  }</font></font></p>
<p><font color="#008000">else {<br />
_root.mc_ball.gotoAndPlay(&#8220;begin&#8221;);<br />
}</font></p>
<blockquote></blockquote>
</blockquote>
<p>Return to the main stage and test your movie. What you should now see is the counter increase by one each time the circle crosses the stage, and when it hits 3, it should stop, and the &#8220;demonstrate again&#8221; text should appear. When you click on this text, the counter should return to zero and the ball should travel across the screen again.</p>
<p>And that&#8217;s all, we are now done! What? You want to know what this code does? Ok&#8230; let me try to explain it:</p>
<p>Actions Scene 1, Frame 1:</p>
<blockquote><p><font color="#000080">var counter = 0</font></p></blockquote>
<p>This adds a varialbe called &#8220;counter&#8221; with a value of &#8220;0&#8243;.</p>
<p>Actions mc_ball, Final Frame:</p>
<blockquote><p><font color="#000080">_root.counter += 1;</font></p></blockquote>
<p>this says to add 1 to our variable called counter which we declared in scene 1</p>
<blockquote><p><font color="#000080">if (_root.counter &gt;= 3) {<br />
_root.mc_ball.stop();<br />
_root.mc_reset.gotoAndStop(&#8220;end&#8221;)<br />
}</font></p></blockquote>
<p>If the counter variable is greater than or equal to 3 (the number of times we want our clip to play), perform the actions between the curly brackets. The actions between the curly brackes are telling the &#8220;mc_ball&#8221; movie clip to stop playing, and it&#8217;s also telling the &#8220;mc_reset&#8221; clip (our Demonstrate Again button&#8230;) to go to the frame labeled &#8220;end&#8221;.</p>
<blockquote><p><font color="#000080">else {<br />
_root.mc_ball.gotoAndPlay(&#8220;begin&#8221;);<br />
}</font></p></blockquote>
<p>If the counter variable is NOT greater than or equall to zero (the requirements we asked for in the &#8220;if&#8221; statement above), perform the actions between the curly brackets. The actions between the curly brackets are telling our &#8220;mc_ball&#8221; movie clip to go back to the begining and play again.</p>
<p>Hopefully that helps explain things, and I&#8217;ve tried to comment the source file for everyone to make sure it&#8217;s clear. As always, I hope you found this tutorial helpful, and if you have any questions or comments please leave them below!</p>
<p>Source Files (Flash 8): <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/playClip3Times.fla"  title="Flash Button Tutorial: Source File">Flash Button Tutorial: Source File</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-play-a-movie-clip-a-set-number-of-times-and-then-stop/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Button using Movie Clip symbol.</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-button-using-movie-clip-symbol/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-button-using-movie-clip-symbol/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 00:16:04 +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>
		<category><![CDATA[design tutorial]]></category>
		<category><![CDATA[flash design]]></category>
		<category><![CDATA[flash development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/flash-tutorial-button-using-movie-clip-symbol/</guid>
		<description><![CDATA[Flash Tutorial: Creating a button using a movieclip and ActionScript
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 button using a movieclip and ActionScript</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><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/button_tut1.swf" />
<embed src="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/button_tut1.swf" type="application/x-shockwave-flash" width="250" height="100" >
</object>
</p>
<p><strong>Description:</strong> In this tutorial, I will explain how to create a button as a movieclip symbol using ActionScript rather than using the button symbol.</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-18"></span>Save the file, and give it the appropriate name. I will call this &#8220;button_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 whatever you would like (I chose red), and a stroke of none. In the property window (Window &gt; Properties &gt; Properties or command-F3), set the corners to rounded at 9 (Fig. 1). 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.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut3_fig1.gif" alt="Button Tutorial figure 1" width="420" height="100" /></p>
<p>You should have a rectangle similar to the Fig. 2.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut3_fig2.gif" alt="Button Tutorial figure 2" width="300" height="124" /></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_button&#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>Now, let&#8217;s add a little styling to our button. Double-click on our new symbol to bring us into the symbol editing mode. Select the rectangle, and Edit &gt; Copy (command-C). In the timeline, name your layer &#8220;button solid&#8221; and create a new layer called &#8220;button highlight&#8221;. Lock the &#8220;button solid&#8221; layer, and move it to the bottom layer. On the &#8220;button highlight&#8221; layer, do a paste in place (Edit &gt; Paste in Place or shift-command-V). With this rectangle selected, change the width to 92 and the height to 5 in the Info pallette (Window &gt; Info or command-I (Fig. 3)), and select a linear gradient fill. In the color pallete, set your gradient scale to be 100% white on one end and 0% white on the other. With the rectangle still selected, select the gradient tool (located with your transform tool in the tools pallette), and rotate your linear gradient to be vertical (Tip: Hold shift when rotating to snap to 45º angles), with the 100% white on the top and the 0% white on the bottom. Also, shrink the gradient tool so that it is the height of your rectangle. Now, position this rectangle slightly below the top edge of your solid rectangle, and centered from side to side. You should have a shape that looks like Fig. 4.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut3_fig3.gif" alt="Button Tutorial figure 3" width="230" height="170" /><br />
<img src="http://www.spitshine-design.com/images/tutorials/tut3_fig4.gif" alt="Button Tutorial figure 4" width="300" height="123" /></p>
<p>Create a new layer, and call it &#8220;text&#8221;. Add a text block centered on your button shape and type &#8220;button&#8221;. You will now have something that looks like Fig. 5.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut3_fig5.gif" alt="" /></p>
<p>We are now done with the first state of our button, and now we can add the functionality that maves our movie clip behave like a button. For that, we will need to add some labels and then modify our button on the different frames.</p>
<p>Still working in your button symbol, add a new layer and call it &#8220;labels&#8221;. On your timeline, add frames to your timeline so that it extends to frame 45 for all layers. Insert a new keyframe (Insert &gt; Timeline &gt; Keyframe or F6) at frame 15 and 30 of the &#8220;labels&#8221; layer. click on frame 1, and in the Properties window, type &#8220;btn_off&#8221;. Repeat the process at Frame 15, but label it &#8220;btn_over&#8221;, label frame 30 &#8220;btn_down&#8221;. Add a new keyframe to the &#8220;button solid&#8221; layer at frame 15 and frame 30. You should now have a timeline that looks similar to Fig. 6.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut3_fig6.gif" alt="Button Tutorial figure 6" width="450" height="95" /></p>
<p>At frame 15, select the &#8220;button solid&#8221; layer, and change the color of your shape, I&#8217;ve used a green for this example. Do the same thing at frame 30 and use a third color, I&#8217;ve used a blue. These color changes are simply for illustrative purposes. You can modify the buttons however you like, I just wanted to show a drastic change for when we add the ActionsScript that gives our movieclip a button functionaily.</p>
<p>We are now ready to start adding some ActionScript. Still within your button symbol, create a new layer, move it to the top of the timeline and label it &#8220;actions&#8221;. Add keyframes at 15 and 30. Click on frame 1 of your &#8220;actions&#8221; layer, and in the Actions panel (Windows &gt; Actions or alt-F9) and add the following code:</p>
<blockquote><p><span style="color: #000080;">stop();</span></p></blockquote>
<p>This simply stops our moviclip from playing automatically (remember, we want the changes to take effect when the mouse rolls over the rectangle, like a button). Add the same ActionScript to the &#8220;actions&#8221; layer at frame 15 and 30. Our button symbol is now complete, so we need to return to the main timeline (Scene 1) where we will be adding the ActionScript that controls the button functionality.</p>
<p>Click on the button symbol, and give it an appropriate instance name in the Property Window. I&#8217;ve used &#8220;mc_button&#8221;. With the symbol still selected (but NOT in editing mode), add the following code to the Actions panel:</p>
<blockquote><p><span style="color: #000080;">on (rollOver) {<br />
_root.mc_button.gotoAndStop(&#8220;btn_over&#8221;);<br />
}</span></p>
<p><span style="color: #000080;">on (rollOut) {<br />
_root.mc_button.gotoAndStop(&#8220;btn_off&#8221;);<br />
}</span></p>
<p><span style="color: #000080;">on (press) {<br />
_root.mc_button.gotoAndStop(&#8220;btn_down&#8221;);<br />
}</span></p>
<p><span style="color: #000080;">on (release) {<br />
_root.mc_button.gotoAndStop(&#8220;btn_off&#8221;);<br />
getURL(&#8220;http://www.spitshine-design.com&#8221;);<br />
}</span></p></blockquote>
<p><strong>UPDATE</strong>: I&#8217;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 (&#8220;). When copying from the Web, it sometimes uses &#8220;smartquotes&#8221;. 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, our movie clip as a button is now complete. Go ahead and test your movie and check the button state change when you roll on, roll off, mouse down or mouse release.</p>
<p>Now I will try and explain the code.</p>
<blockquote><p><span style="color: #000080;">on (rollOver) {</span></p></blockquote>
<p>This is saying when the user rolls their mouse over the button, perform the actions within the curly brackets.</p>
<blockquote><p><span style="color: #000080;">_root.mc_button.gotoAndStop(&#8220;btn_over&#8221;);</span><br />
<span style="color: #000080;">}</span></p></blockquote>
<p>This is telling flash to go to the instance of &#8220;mc_button&#8221;, and go to the frame labeled &#8220;btn_over&#8221; and stop.</p>
<blockquote><p><span style="color: #000080;">on (rollOut) {</span><br />
<span style="color: #000080;">_root.mc_button.gotoAndStop(&#8220;btn_off&#8221;);</span><br />
<span style="color: #000080;">}</span></p>
<p><span style="color: #000080;">on (press) {</span><br />
<span style="color: #000080;">_root.mc_button.gotoAndStop(&#8220;btn_down&#8221;);</span><br />
<span style="color: #000080;">}</span></p>
<p><span style="color: #000080;">on (release) {</span><br />
<span style="color: #000080;">_root.mc_button.gotoAndStop(&#8220;btn_off&#8221;);</span><br />
<span style="color: #000080;">getURL(&#8220;http://www.spitshine-design.com&#8221;);</span><br />
<span style="color: #000080;">}</span></p></blockquote>
<p>This code is basically doing the same thing as above for the various mouse events (roll off, click and release).</p>
<blockquote><p><span style="color: #000080;">getURL(&#8220;http://www.spitshine-design.com&#8221;); </span></p></blockquote>
<p>This is the destination URL for when a user releases the mouse button while over the button. You can set this url to whatever you like.</p>
<p>While this tutorial seems pretty lengthy, it&#8217;s really because I wanted to be as detailed as possible so users can understand what is happening. Once you do this once or twice, I think you will find that creating movie clip buttons is fast and simple, and as you learn more about Flash, you will be able to create more animated buttons rather than just a simple color change. I plan to do another tutorial in the near future that illustrates some of the advanced effects you can apply to a button when you create it using the movie clips symbol as opposed to the button symbol.</p>
<p>I hope this <a href="http://mikestickney.com/wordpress/category/flash-tutorial/" >Flash tutorial</a> was helpful, and as always comments, questions or feedback are always welcome!</p>
<p><strong>Source files:</strong> <a title="Flash Button Tutorial: Source File" href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/button_tut1.fla" >Flash Button Tutorial: Source File</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-button-using-movie-clip-symbol/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Flash Tutorial: Play movie clip with mouse click</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 22:08:56 +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>
		<category><![CDATA[design tutorial]]></category>
		<category><![CDATA[flash design]]></category>
		<category><![CDATA[flash development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click/</guid>
		<description><![CDATA[Update: I have written a second tutorial on playing a movie clip on mouse click that provides a different option for accomplishing this task. Check it out here.
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, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: I have written a second <a href="http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click-version-2/" >tutorial on playing a movie clip on mouse click</a> that provides a different option for accomplishing this task. <a href="http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click-version-2/" >Check it out here</a>.</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><strong>Description:</strong> This is the next step to our Flash Target Game, which I started in a tutorial for a <a href="http://mikestickney.com/wordpress/flash-tutorial-custom-mouse-pointer/" >custom mouse pointer</a>. Ideally you would want to continue with those files, but you should still be able to learn how to play a movie clip with a mouse click in Flash through this tutorial.</p>
<p><strong>Demo:</strong> <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/target_tut_2_fla8.swf"  title="Play movieclip with mouse click: Demo">Play movieclip with mouse click: Demo</a></p>
<p><strong>Let’s get started!</strong></p>
<p>What we will be doing is adding a simple bullet or firing action to the scope that will be activated with the click of the mouse.  <span id="more-15"></span>Let&#8217;s start with the final file from the <a href="http://mikestickney.com/wordpress/flash-tutorial-custom-mouse-pointer/" >previous tutorial</a> (download the file here: <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/target_tut_1_fla8.fla"  title="Flash tutorial: Custom mouse pointer">Flash tutorial: Custom mouse pointer</a>). Select “File &gt; Open” (command-”O”) to open the .fla file. Do a &#8220;Save As&#8221;, and give it the appropriate name. I will call this “target_tut_2.fla”.</p>
<p>On the &#8220;scope&#8221; layer, double click on the image to bring us into the &#8220;mc_scope&#8221; editing stage. Double click on the outer circle to select it, and copy (Edit &gt; Copy or command-C). Create a new layer, and do a Paste in Place (Edit &gt; Paste in Place or shift-command-V). With our circle still selected, set the fill color to one of the radial gradients on the bottom of the color selector palette, and change the stroke to none. Move this layer to the bottom of the timeline, and lock all other layers. With the circle selected,  you should be able to set the color of the gradient by clicking on the small square on the color scale in the color palette (Window &gt; Color or shift-F9 (Fig. 1)),  (<strong>Tip:</strong> be sure to select the color square on the gradient scale and not the paint bucket in the upper left corner of the color palette). Double click on the smaller square on the gradient scale and select a bright yellow (#ffff00). You should now have a circle with a yellow center and black edge, underneath our &#8220;scope&#8221; image (Fig. 2).</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut2_fig1.gif" alt="Flasht Tutorial Image 1" height="365" width="250" /><img src="http://www.spitshine-design.com/images/tutorials/tut2_fig2.gif" alt="Flash Tutorial image 2" align="top" height="126" width="148" /></p>
<p>Double click on our new circle again, and convert this to a movie clip symbol (Modify &gt; Convert to Symbol or F8). Be sure to select the &#8220;movie clip&#8221; radial, and then give it an appropriate name, I will call this &#8220;mc_bullet&#8221;. Also, we need to give this clip an instance name in the Property panel. I like to use the same instance name as my symbol name, in this case &#8220;mc_bullet&#8221;. What we will be doing is animating this symbol to make a &#8220;shooting&#8221; effect. To do this, let&#8217;s double-click on the symbol to take us into the editing mode.  Once in editing mode, we need to select the circle and convert this to a symbol again, but this time we need to make this a graphic symbol, and give it a new name, I will call mine &#8220;img_bullet&#8221;. Add a new keyframe (Insert &gt; Timeline &gt; Keyframe or F6) on frame 6 on the timeline. Now, on frame 6, select our symbol and scale it to 0%. Select any frame between 1 and 5, and create a motion tween (Insert &gt; Timeline &gt; Create Motion Tween). What you now have is a very quick animation of the circle going from very full size, to very tiny (disappearing). The last thing we need is for our clip to start with a blank or empty frame, so to do this, on the layer with our circle, drag keyframe 1 to keyframe 2. You should now have a timeline that looks similar to Fig. 3 below. We now need to add some ActionScript to control this movie clip.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut2_fig3.gif" alt="Flash Tutorial image 3" height="90" width="385" /></p>
<p>Create a new layer, move it to the top and name it &#8220;actions&#8221;. On the first frame of this layer, insert the following code in the Actions window (Windows &gt; Actions or alt-F9):</p>
<blockquote><p><font color="#000080">stop();</font></p></blockquote>
<p>What this does is stop our movie clip from playing because we only want it to play when we click our mouse. Click on frame 6 of the actions layer and insert a blank keyframe (Insert &gt; Timeline &gt; Blank Keyframe or F6). On this keyframe add the following code to the Actions window:</p>
<blockquote><p><font color="#000080">gotoAndStop(1);</font></p></blockquote>
<p>What this does is send our playhead back to the start of our clip, and stops it since again, we only want it to play when we click our mouse.</p>
<p>Let&#8217;s go ahead and test our movie. You&#8217;ll notice that nothing is really happening. This is because we haven&#8217;t set the ActionScript that tells this movie clip to &#8220;fire&#8221; our bullet. Let&#8217;s go back to our Flash document. Go to the main timeline of our movie (Scene 1) and click on the frame 1 of the &#8220;actions&#8221; layer and open the actions window (Window &gt; Actions or alt-F9). You should already have the following code from the previous tutorial (or something very similar):</p>
<blockquote><p><font color="#000080">_root.onEnterFrame = function() {<br />
Mouse.hide();</font></p>
<p><font color="#000080">mc_scope._x = _xmouse;<br />
mc_scope._y = _ymouse;<br />
} </font></p></blockquote>
<p>Remember from our last tutorial that this controls the movement of our &#8220;scope&#8221;. Directly below this code, add the following line of code:</p>
<blockquote><p><font color="#000080">onMouseDown = function() {<br />
_root.mc_scope.mc_bullet.play();<br />
} </font></p></blockquote>
<p>This is the code that will tell our &#8220;bullet&#8221; to &#8220;fire&#8221;. Here is the code explained:</p>
<blockquote><p><font color="#000080">onMouseDown = function () {</font></p></blockquote>
<p>This line basically is saying, whenever the user clicks on their mouse button (onMouseDown), perform the actions between  the curly brackets.</p>
<blockquote><p><font color="#000080"> _root.mc_scope.mc_bullet.play();<br />
}</font></p></blockquote>
<p>This is telling our &#8220;mc_bullet&#8221; movieclip to play. Note that our &#8220;mc_bullet&#8221; movie clip is a &#8220;nested&#8221; movie clip, which means it is placed within our  mc_scope symbol. Our action needs to provide the path to our mc_bullet movieclip. So in this example:</p>
<blockquote><p><font color="#000080">_root</font> = the main timeline (Scene 1)<br />
<font color="#000080">.mc_scope</font> = the instance name of our &#8220;scope&#8221; movieclip<br />
<font color="#000080">.mc_bullet</font> = the instance name of our &#8220;bullet&#8221; animation</p></blockquote>
<p>Go ahead and test your movie again. This time, the mouse should still control the movement of the scope, and when you click the mouse button, you should see the animation of the &#8220;bullet&#8221; circle take place.</p>
<p>I hope you found this <a href="http://mikestickney.com/wordpress/category/flash-tutorial/"  title="Spitshine Design Flash Tutorials">Flash tutorial</a> helpful, and as always feel free to leave any comments or questions below. Also, check out a second <a href="http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click-version-2/" >tutorial on playing a movie clip on mouse click</a> that provides a different option for accomplishing this task.</p>
<p><strong>Source Files: </strong><a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/target_tut_2_fla8.fla"  title="Play movieclip with mouse click: Source File">Play movieclip with mouse click: Source File</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Flash tutorial: Custom mouse pointer</title>
		<link>http://mikestickney.com/wordpress/flash-tutorial-custom-mouse-pointer/</link>
		<comments>http://mikestickney.com/wordpress/flash-tutorial-custom-mouse-pointer/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 01:11:15 +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>
		<category><![CDATA[design tutorial]]></category>
		<category><![CDATA[flash design]]></category>
		<category><![CDATA[flash development]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/flash-tutorial-custom-mouse-pointer/</guid>
		<description><![CDATA[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 of Flash) and instructions are for the Mac. Windows [...]]]></description>
			<content:encoded><![CDATA[<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><a href="images/tutorials/target_tut_1_fla8.fla" title="Flash Tutorial: Custom Mouse Pointer"></a><strong>Description:</strong> In this tutorial, I will explain how to make a pointer or scope that could possibly be used for a shooting or target game. As with many things in Flash, there are different ways to accomplish this, but I found this to be pretty straight forward and simple. In future tutorials, I will be explaining more steps on how to create a target shooting game, but this is a starting tutorial and will get you acquainted with Flash and ActionScript.</p>
<p><strong>Demo:</strong> <a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/target_tut_1_fla8.swf"  title="Custom Mouse Pointer Flash Tutorial: Demo">Custom Mouse Pointer Flash Tutorial: Demo</a></p>
<p><strong>Let&#8217;s get started!</strong></p>
<p>Select &#8220;File &gt; New&#8221; (command-&#8221;N&#8221;) <span id="more-12"></span>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;target_tut_1.fla&#8221;. Feel free to change the document dimensions (&#8220;Modify &gt; Document or &#8220;command-J&#8221;), to whatever you like, but I chose to use 300 x 300 pixels.</p>
<p>The first thing I will do is draw the pointer or &#8220;scope&#8221;, similar to what you see in the movies when a sniper looks through the scope of a rifle. Select the &#8220;Oval tool&#8221; from your tool box, and use a red stroke, with no fill. Draw a small circle on the stage (<strong>Tip:</strong> holding shift when you drag the mouse will create a perfect circle). Select the entire circle and go to &#8220;Modify &gt; Convert to Symbol&#8221; (F8). Give this an appropriate name (I will use &#8220;mc_scope&#8221;) and select the &#8220;Movie Clip&#8221; radial. Your circle is now a symbol. We will now need to edit the symbol to complete the &#8220;scope&#8221; look. Double click on the circle to bring you into the symbol. Select the entire cirlce (<strong>Tip:</strong> you will see white dots in the circle as opposed to a blue square around the circle if you are in the symbol editing mode when the shape is selected). Add a new layer to the symbol, and choose &#8220;Edit &gt; Past in Place&#8221; (command-shift-V) to add another circle to the new layer. Select one layer (either one, it doesn&#8217;t matter), and scale this circle to 50%. (<strong>Tip:</strong> to easily scale an object, use the &#8220;Transform&#8221; pallette: &#8220;Windows &gt; Transform&#8221; (command-T).</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>We now have one smaller cirlce inside a larger one (Fig. 1)&#8230; we now need to add the crosshairs. What we want to do is draw a cross in the center of the circle. One easy way I do this is select the outer circle and choose the transform tool. What this will do is give you a box around the outer circle with &#8220;handles&#8221; (small squares used to manipulate or &#8220;transform&#8221; the object) on all corners, and at the halfway point of each dimension. These can be used as qucik visual in order to drag guides out and find the exact center of the circle. Simply drag a top and side guide and drop on the handles at the center points of the box (Fig 2, the green lines are Flash guidelines). Now, using the line tool, we can draw a vertical and horizontal line through the circles on the guide lines (<strong>Tip:</strong> hold &#8220;shift&#8221; while dragging to create a perfectly straight line). You want to extend the lines beyond the edges of the outer circle. A little lenghty desciption here, but you should now have your scope image.</p>
<p><img src="http://www.spitshine-design.com/images/tutorials/tut1_fig1.gif" alt="Flash Tutorial image 1" border="0" height="129" hspace="0" vspace="0" width="150" /><img src="http://www.spitshine-design.com/images/tutorials/tut1_fig2.gif" alt="Flash Tutorial image 2" border="0" height="151" hspace="0" vspace="0" width="150" /></p>
<p>Return to the main stage (clicking &#8220;scene 1&#8243; under the timeline). Click on the symbol once to select it, and with it selected, give the symbol an appropriate instance name in the &#8220;Properties&#8221; window. A personal preference of mine is to give it the same instance name as the symbol name, in this case &#8220;mc_scope&#8221;, but it is important to note that symbol name and instance name do not refer to the same thing. I will be writing a mini-tutorial on the difference between a &#8220;symbol&#8221; name and an &#8220;instance&#8221; name, but until then, feel free to leave a comment. Now that we have given our symbol an instance name, it&#8217;s time to get to the fun part&#8230;. adding the ActionScript!</p>
<p>On the main movie timeline, add a new layer and name it &#8220;actions&#8221;. (<strong>Tip:</strong> Although not absolutely necessary, it is good practice to always place your actions layer on the top layer of your document). On the first keyframe of the &#8220;actions&#8221; layer, insert the following code:</p>
<blockquote><p><font color="#000080">_root.onEnterFrame = function() {</font></p>
<p><font color="#000080">mc_scope._x = _xmouse;<br />
mc_scope._y = _ymouse;<br />
}</font></p></blockquote>
<p>(<strong>Tip:</strong> Where the code reads &#8220;mc_scope&#8221;, you would need to change to whatever you used as the instance name for your movie clip symbol.)</p>
<p>That&#8217;s it! We are now done! You can go ahead and test your movie. Cool huh? What? you thought there would be long lines of crazy, confusing code? Nope. Just a couple lines. Pretty simple, right?</p>
<p>Ok, so did you think I was going to leave it at that without explaining the code? Of course not! Here we go&#8230;.</p>
<blockquote><p><font color="#000080">_root.onEnterFrame = function() {</font></p></blockquote>
<p>The &#8220;onEnterFrame&#8221; command is telling the Flash player to perform the actions within the curly brackets whenever the playhead is on that frame.</p>
<blockquote><p><font color="#000080">mc_scope._x =_xmouse;<br />
mc_scope._y = _ymouse;<br />
}</font></p></blockquote>
<p>The code between the curly brackets is what is controlling the X and Y position of the instance &#8220;mc_scope&#8221; and matching it up to the X and Y postion of the mouse. Sound confusing?</p>
<p>Basically, _xmouse is the X position of the users mouse on the stage&#8230; and therefore _ymouse is the Y position. Whenever the user moves their mouse on the file, these numbers will change. What we are doing is simply saying &#8220;whatever the X and Y position of the users mouse is, make that the X and Y postion of mc_scope as well&#8221;. Simple as that!</p>
<p>When you test the movie, you will see your mouse pointer on the stage, and wherever you move the mouse pointer, your scope will follow. I left the mouse visible to give you a better visual of what exactly is happening with the code. However, what we probably want for a more &#8220;realistic&#8221; look is to &#8220;hide&#8221; the mouse pointer and just have our scope be our mouse pointer. To do this we simply add the following line of after the opening curly bracket:</p>
<blockquote><p><font color="#000080">Mouse.hide();</font></p></blockquote>
<p>This, as you can probably guess, &#8220;hides&#8221; the mouse pointer from the stage. However, the X and Y coordinates of where the mouse pointer would be are still established, so our code is still operating the way it should be.</p>
<p>Now, we are done with the first stage of a target game. Again, as with many tasks in Flash, there are multiple ways to do things, and this is just one, but I hope you found this exlpanation helpful, and I hope to continue writing more tutorials to finish a complete target shooting game.</p>
<p>As always, comments are welcome, whether you have question or maybe you have a better way to do this, I&#8217;d love to hear it!</p>
<p><strong>Source Files: </strong><a href="http://mikestickney.com/wordpress/wp-content/uploads/2008/03/target_tut_1_fla8.fla"  title="Flash tutorial: Custom mouse pointer">Flash tutorial: Custom mouse pointer</a></p>
<p>If you liked this tutorial, check out the second part: Adding the bullet animation and <a href="http://mikestickney.com/wordpress/flash-tutorial-play-movie-clip-with-mouse-click/" >learn to play a movie clip with the mouse click in Flash</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikestickney.com/wordpress/flash-tutorial-custom-mouse-pointer/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Spitshine-design.com is LIVE (well, sort of&#8230;)</title>
		<link>http://mikestickney.com/wordpress/spitshine-designcom-is-live-well-sort-of/</link>
		<comments>http://mikestickney.com/wordpress/spitshine-designcom-is-live-well-sort-of/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 02:18:02 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Graphic design]]></category>
		<category><![CDATA[Print Design]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[flash development]]></category>
		<category><![CDATA[online marketing]]></category>
		<category><![CDATA[portfolio]]></category>

		<guid isPermaLink="false">http://mikestickney.com/wordpress/spitshine-designcom-is-live-well-sort-of/</guid>
		<description><![CDATA[Ok, so when I started this site about 3 weeks ago, I set myself  a deadline of March for the simple reason being, I HATE missing deadlines, so I knew I&#8217;d force myself to get it done. And since I hate missing deadlines, I actually worked quite a bit these last few weeks, and [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so when I started this site about 3 weeks ago, I set myself  a deadline of March for the simple reason being, I HATE missing deadlines, so I knew I&#8217;d force myself to get it done. And since I hate missing deadlines, I actually worked quite a bit these last few weeks, and I am very happy to say I am ahead of schedule (again, sort of&#8230;). Tonight, I launched the last piece of this Web site puzzle which was my <a title="Graphic and Web Design Portfolio for Spitshine Design" href="http://www.spitshine-design.com/portfolio.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.spitshine-design.com');">graphic and Web design portfolio</a>.</p>
<p><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>So what do I mean by &#8220;sort of&#8221;? Well, I say &#8220;sort of&#8221; because I just put up a handful of design projects, definitely not the full scope of my <a title="Graphic and Web Design Portfolio for Spitshine Design" href="http://www.spitshine-design.com/spitshine-graphic-design-portfolio.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.spitshine-design.com');">graphic design portfolio</a>, or all of my <a title="Website Designs" href="http://www.spitshine-design.com/spitshine-website-design.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.spitshine-design.com');">Web design</a> and <a title="Flash Design and Development" href="http://www.spitshine-design.com/spitshine-flash-design.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.spitshine-design.com');">Flash development projects</a>.</p>
<p><span id="more-8"></span></p>
<p>I still have quite a few items that I&#8217;d like to get up there, and I fully intend to, very soon in fact.  Which is why I left the launch date of March 2008 (notice, I wasn&#8217;t specific as to what day in March&#8230;). But at least there&#8217;s enough up there to start to get my work seen by others.</p>
<p>I&#8217;ve really been enjoying looking at some of my older projects, even the student work that I&#8217;ve done, and see the good (and unfortunately not-so-good) work that I&#8217;ve done. I&#8217;ve seen some real progression in my work. I have even posted some graphic design projects from college, so check out the portfolio and see if you can see any improvement. I plan to post some more of my &#8220;older&#8221; work soon, as well as some new stuff I haven&#8217;t even finished yet, so check back soon for updates. And of course there are the design tutorials that I&#8217;ve been planning on doing, so hopefully I can get those up soon too.</p>
<p>I also say &#8220;sort of&#8221;, because this being a one-man show (in my spare time to boot), there are definitely some kinks to be worked out. But at least with things live, I can get things checked out, and hopefully have some others take a look and catch things I might have missed by staring at it too long. So check things out, and feel free to comment (constructive criticism is always welcome) and let me know what you think.</p>
<p><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/spitshine-designcom-is-live-well-sort-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
