<?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 design</title>
	<atom:link href="http://mikestickney.com/wordpress/tag/flash-design/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: 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>
	</channel>
</rss>
