<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3" -->
<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/"
	>

<channel>
	<title>flizash.com</title>
	<link>http://flizash.com</link>
	<description>Flash Tutorials, Actionscript, and Animation</description>
	<pubDate>Tue, 04 Mar 2008 21:03:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3</generator>
	<language>en</language>
			<item>
		<title>Time Based Animation in ActionScript 3.0</title>
		<link>http://flizash.com/2008/03/04/time-based-animation-in-actionscript-30/</link>
		<comments>http://flizash.com/2008/03/04/time-based-animation-in-actionscript-30/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 21:02:06 +0000</pubDate>
		<dc:creator>Brent</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

		<category><![CDATA[animation]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Objects]]></category>

		<category><![CDATA[Stage]]></category>

		<category><![CDATA[time based]]></category>

		<guid isPermaLink="false">http://flizash.com/2008/03/04/time-based-animation-in-actionscript-30/</guid>
		<description><![CDATA[Learn how to use a time based technique for animating your objects to avoid speed changes when adjusting your frame rate.]]></description>
			<content:encoded><![CDATA[<p>Here I will be showing you another techique that can be used to animate your objects using time in ActionScript 3.0, rather than frames, as the basis for how far your objects move.  I previously wrote about <a href="http://flizash.com/2008/01/25/frame-based-animation-in-as3/">frame based animation</a> if you would like to review that.  One major advantage of time based animation is that it allows you to adjust the frame rate of your movie without affecting the speed of any objects you have animated via ActionScript.  For example, when relying on frames, you would tell an object to move a certain number of pixels each frame.  If your movie was first set to 15 frames per second and then adjusted to 30, the speed of your objects would double.  Let&#8217;s get to it and see how time based animation avoids this problem!</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-4636375906111852";
//468x60, content
google_ad_slot = "7009034018";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center></p>
<p>For my setup here, I have simply drawn my trusty red circle onto the stage and converted it to a movie clip, which I gave an instance name of <strong>myCircle</strong>.</p>
<p align="center"><img src="http://flizash.com/images/time_based_animation/step1.jpg" alt="Instance Name" width="169" height="65"></p>
<p align="left">Next I start in with ActionScript. Open up your editor (F9) and let&#8217;s get to it. First we create a new integer variable called oldTime:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> oldTime:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p align="left">What this does is store the amount of time that has passed since the movie started, in milliseconds, using the getTimer() function (built into Flash). Next we will add an event listener that will run once per frame:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>3
</pre></td><td class="code"><pre class="actionscript">addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, moveCircle<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p align="left">As you can see, the event listener calls a function called <strong>moveCircle</strong>, which we will create now:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>5
6
7
8
9
</pre></td><td class="code"><pre class="actionscript"><span style="color: #000000; font-weight: bold;">function</span> moveCircle<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> interval:<span style="color: #0066CC;">int</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - oldTime;
	oldTime += interval;
	myCircle.<span style="color: #006600;">x</span> += interval * <span style="color: #cc66cc;">0.1</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p align="left">Here is what is happening with the function, line by line:</p>
<p align="left"><strong>Line 5</strong>: Declare the function and set it to accept the ENTER_FRAME event.</p>
<p align="left"><strong>Line 6</strong>: Create a new integer variable called <strong>interval</strong>. This variable again calls the getTimer() function to grab the amount of time that has passed since the movie started. It then subtracts from it the variable we created earlier, <strong>oldTime</strong>. This will be further explained in a moment.</p>
<p align="left"><strong>Line 7</strong>: Add the <strong>interval</strong> variable that we just calculated to the <strong>oldTime</strong> variable. This will constantly increase this variable each time the function runs, once per frame.</p>
<p align="left"><strong>Line 8</strong>: Here is where the circle animates. Set the x property of the circle equal to the interval variable we created, which has been multiplied by 0.1 This is further explained below.</p>
<p align="left"><strong>Line 9</strong>: Ends the function.</p>
<p align="left">If you run through this function hypothetically, you can see how this is working. So that the math is easier to follow, let&#8217;s say that the movie has been set to 10 frames per second. When the movie first loads, the <strong>oldTime</strong> variable is set. Since no time has passed, we&#8217;ll say that the variable is equal to 0. Since we are working with milliseconds here, it&#8217;s helpful to point out that 1 second is equal to 1000 milliseconds. We are running at 10fps, therefore each frame runs about 100 milliseconds apart.</p>
<p align="left">Running through the function, the first thing that happens is that <strong>interval</strong> is set to the getTimer() value. On the next frame to run, that value would be 100. We then subtract <strong>oldTime</strong>, which is currently set to 0. Therefore <strong>interval</strong> is set to 100. Next, oldTime is set to itself plus interval, or 0 + 100&#8230;oldTime now equals 100 as well, and that is to setup the next iteration of the function. The circle&#8217;s x property is then set to interval * 0.1, or 100 * 0.1, which equals 10. Therefore the circle is redrawn 10 pixels to the right of where it was previously. If you increase the value of 0.1 to 0.5, the circle would be redrawn 50 pixels to the right each frame, speeding it up significantly (100 * 0.5 = 50). If you were to increase the frame rate, the calculation is adjusted because the interval variable would be lower.</p>
<p align="left">Hopefully I explained that half decent&#8230;if I didn&#8217;t, just increase the 0.1 to speed it up, decrease it to slow it down. Click the download link below to get the source .fla.</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-4636375906111852";
//468x60, content
google_ad_slot = "7009034018";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center></p>
<p align="center"><a href="http://flizash.com/images/time_based_animation/time_based.zip">Download Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flizash.com/2008/03/04/time-based-animation-in-actionscript-30/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Frame based Animation In AS3</title>
		<link>http://flizash.com/2008/01/25/frame-based-animation-in-as3/</link>
		<comments>http://flizash.com/2008/01/25/frame-based-animation-in-as3/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 21:33:51 +0000</pubDate>
		<dc:creator>Brent</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

		<category><![CDATA[animation]]></category>

		<category><![CDATA[AS3]]></category>

		<category><![CDATA[basics]]></category>

		<category><![CDATA[event listener]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[linkage]]></category>

		<category><![CDATA[Mouse]]></category>

		<category><![CDATA[movie clip]]></category>

		<category><![CDATA[Objects]]></category>

		<category><![CDATA[pixel]]></category>

		<category><![CDATA[Stage]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://flizash.com/2008/01/25/frame-based-animation-in-as3/</guid>
		<description><![CDATA[Learn how to make an easy flash animation in ActionScript 3.0.  This tutorial uses frame-based animation.]]></description>
			<content:encoded><![CDATA[<p>First, to set the stage here, I have drawn a circle, converted it to a movie clip, and set the linkage to &#8220;circle&#8221;.  If you do not know how to setup the linkage for an object so that we may use it ActionScript, please refer to my previous tutorial - <a href="http://flizash.com/2007/11/12/respond-to-mouse-clicks-in-actionscript-30/">responding to mouse clicks</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4636375906111852";
//468x60, content
google_ad_slot = "7009034018";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The first thing I need to do is place the object on the stage, as I explained in <a href="http://flizash.com/2007/11/07/placing-an-object-on-the-stage-using-actionscript-30/">placing an object on the stage</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> hero:circle = <span style="color: #000000; font-weight: bold;">new</span> circle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
hero.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">5</span>;
hero.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">5</span>;
addChild<span style="color: #66cc66;">&#40;</span>hero<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Next, we setup an event listener to the stage that will run once per frame:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>6
</pre></td><td class="code"><pre class="actionscript"><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, moveCircle<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>That event listener calls a function called <strong>moveCircle, </strong>which we create next:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>8
9
10
</pre></td><td class="code"><pre class="actionscript"><span style="color: #000000; font-weight: bold;">function</span> moveCircle<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	hero.<span style="color: #006600;">x</span> += <span style="color: #cc66cc;">1</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>What this function does is, as you can see on <strong>line 9,</strong> is find out what the x property is of our object, and then add 1 to it. What that means is that every time our flash movie runs a frame, this function runs and moves the circle to the right 1 pixel, because the x property increases by 1 each time. If you subtract from the x property, your object moves to the left. If you use the y property instead of x, your circle can be controlled vertically. Adding to y will move the circle down, subtracting will move it up.</p>
<p>That is all there is to the basics of frame-based animation. There are other ways to animate objects that I will show you in later tutorials.</p>
<p>Click the download link below to obtain the source .fla for this simple example. </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4636375906111852";
//468x60, content
google_ad_slot = "7009034018";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p align="center">	<a href="basic_animation.zip">Download Source</a></p>
<p align="center">&nbsp;</p>
<p align="left">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://flizash.com/2008/01/25/frame-based-animation-in-as3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Respond To Mouse Clicks In ActionScript 3.0</title>
		<link>http://flizash.com/2007/11/12/respond-to-mouse-clicks-in-actionscript-30/</link>
		<comments>http://flizash.com/2007/11/12/respond-to-mouse-clicks-in-actionscript-30/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 21:17:37 +0000</pubDate>
		<dc:creator>Brent</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Click]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Interactive]]></category>

		<category><![CDATA[Mouse]]></category>

		<guid isPermaLink="false">http://flizash.com/2007/11/12/respond-to-mouse-clicks-in-actionscript-30/</guid>
		<description><![CDATA[This tutorial will show you how to create on object on the stage in response to a mouse click.]]></description>
			<content:encoded><![CDATA[<p><script src="http://flizash.com/Scripts/AC_RunActiveContent.js" type="text/javascript"></script></p>
<p>To start off, I have an empty stage with a couple of assets in the library. I have a circle which I have converted to a movie clip named &quot;Circle&quot;, and a rectangle which I have also converted to a movie clip that I named &quot;Button&quot;.</p>
<p align="center"><!--adsense#468_orange--></p>
<p align="center"><img src="http://flizash.com/images/respond_to_mouse_clicks/step1.jpg" alt="step 1" width="196" height="233"></p>
<p align="left">We need to export both of these objects for actionscript. Right-click on the Button object and select <strong>Linkage</strong>. Check the <strong>Export for ActionScript</strong> box in the dialog box presented below.</p>
<p align="center"><img src="http://flizash.com/images/respond_to_mouse_clicks/step2.jpg" alt="step 2" width="442" height="237"></p>
<p align="left">Click <strong>OK</strong> when finished. Click <strong>OK</strong> again if you get a warning from Flash. This warning only serves to inform you that Flash will create a class for the object automatically. Repeat the above steps with the Circle object.</p>
<p align="center"><img src="http://flizash.com/images/respond_to_mouse_clicks/step3.jpg" alt="step 3" width="442" height="232"></p>
<p align="left">Drag an instance of the Button object onto the stage. The goal here is to have the user click the rectangle, then place an instance of the Circle object onto the stage. I have placed mine in the lower right corner.</p>
<p align="center"><img src="http://flizash.com/images/respond_to_mouse_clicks/step4.jpg" alt="step 4" width="361" height="210"></p>
<p align="left">Select the rectangle on the stage and give it an instance name in the <strong>Properties</strong> panel. I named mine &quot;button1&quot;.</p>
<p align="center"><img src="http://flizash.com/images/respond_to_mouse_clicks/step5.jpg" alt="step 5" width="296" height="81"></p>
<p align="left">Add a new layer to your timeline called &quot;actions&quot;. Click inside of frame 1 and open your actionscript editor with the F9 key.</p>
<p align="center"><img src="http://flizash.com/images/respond_to_mouse_clicks/step6.jpg" alt="step 6" width="196" height="62"></p>
<p align="left">The first thing we will do is make it so that when a user hovers the mouse over the rectangle, the cursor changes to indicate that this object is clickable. Type the following actionscript onto line 1:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="actionscript">button1.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">true</span>;</pre></td></tr></table></div>

<p align="left">This line accesses the <strong>buttonMode</strong> property of the button1 object. Setting this to true will cause the cursor to change when hovering your mouse over it. Press <strong>ctrl + enter</strong> to test your movie and see for yourself. Next we must add an Event Listener to the button1 object so that it will respond to a mouse click. Enter the following actionscript on line 2:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
</pre></td><td class="code"><pre class="actionscript">button1.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, onClick<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p align="left">This calls the <strong>addEventListener</strong> method of the button1 object. It takes 2 parameters, first the event to listen for (in this case, a mouse click), the second is the function to call when the event takes place (in this case, onClick). You can read this line to say &quot;when a user clicks on button1, call the onClick function.&quot; Right now our button listens for a mouse click, but doesn&#8217;t do anything yet because we haven&#8217;t created the function that it calls. To do that, add the following actionscript, starting on line 4:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>4
5
6
7
8
9
</pre></td><td class="code"><pre class="actionscript"><span style="color: #000000; font-weight: bold;">function</span> onClick<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> circle1:Circle = <span style="color: #000000; font-weight: bold;">new</span> Circle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	circle1.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;
	circle1.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">10</span>;
	addChild<span style="color: #66cc66;">&#40;</span>circle1<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p align="left"><strong>Line 4</strong>: This line declares the function, onClick, and says that it will accept a MouseEvent. :void means that the function will not be returning any data. The { bracket signifies the start of the code that the function will run when called.</p>
<p align="left"><strong>Line 5</strong>: Here we are creating a new instance of the Circle class, and I called mine &quot;circle1&quot;.</p>
<p align="left"><strong>Lines 6 and 7</strong>: Set the x and y properties of the circle1 object. This will place the circle 10 pixels from the top and 10 pixels from the left of the stage.</p>
<p align="left"><strong>Line 8</strong>: This adds the circle1 object to the display list, allowing Flash to render it to the stage.</p>
<p align="left"><strong>Line 9</strong>: The } bracket signifies the end of our function.</p>
<p align="left">Press <strong>ctrl + enter</strong> to test the movie. I have published my version below, click the green button to see it at work.</p>
<p align="center">
  <script type="text/javascript">
AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0","width","350","height","200","title","example movie","src","http://flizash.com/images/respond_to_mouse_clicks/respond_to_mouse_clicks","quality","high","pluginspage","http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash","movie","http://flizash.com/images/respond_to_mouse_clicks/respond_to_mouse_clicks" ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="200" title="example movie"></p>
<param name="movie" value="http://flizash.com/images/respond_to_mouse_clicks/respond_to_mouse_clicks.swf">
<param name="quality" value="high">
    <embed src="http://flizash.com/images/respond_to_mouse_clicks/respond_to_mouse_clicks.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="200"></embed><br />
  </object></noscript>
</p>
<p align="left">One thing to note here is that the onClick function is run every time you click on the green button. In our example, what that will do is create a new circle at the same x and y positions over and over, hiding the previous circles underneath. There are several ways to prevent things like this from happening, but for the purposes of this tutorial we are only learning how to create on object on the stage in response to a mouse event. One such solution would be to create the circle before the function is called, and then setting the x and y positions and adding it to the display list inside the function.</p>
<p align="left">Click the download link below to download the source .fla.</p>
<p align="center"><!--adsense#468_orange--></p>
<p align="center"><a href="http://flizash.com/images/respond_to_mouse_clicks/respond_to_mouse_clicks.zip">Download Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flizash.com/2007/11/12/respond-to-mouse-clicks-in-actionscript-30/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Placing An Object On the Stage Using ActionScript 3.0</title>
		<link>http://flizash.com/2007/11/07/placing-an-object-on-the-stage-using-actionscript-30/</link>
		<comments>http://flizash.com/2007/11/07/placing-an-object-on-the-stage-using-actionscript-30/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 02:33:30 +0000</pubDate>
		<dc:creator>Brent</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

		<category><![CDATA[AS3]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Objects]]></category>

		<category><![CDATA[Stage]]></category>

		<guid isPermaLink="false">http://flizash.com/2007/11/07/placing-an-object-on-the-stage-using-actionscript-30/</guid>
		<description><![CDATA[This tutorial will show you step-by-step how to place any object in your library onto the stage using Actionscript 3.0.  Source fla is included at the end of the tutorial.]]></description>
			<content:encoded><![CDATA[<p>OK, to set this tutorial up I&#8217;ve created a movie clip of a circle that I named simply &quot;Circle&quot;. I have not placed the circle anywhere on the stage using Flash, I have nothing but a blank stage.</p>
<p align="center"><!--adsense#468_orange--></p>
<p align="center"><img src="http://flizash.com/images/place_on_stage/step1.jpg" alt="step 1" width="196" height="208"></p>
<p>The first thing we need to do is export the movie clip for use in our actionscript. Right-click on your movie clip in the library and click <strong>Linkage.</strong></p>
<p align="center"><img src="http://flizash.com/images/place_on_stage/step2.jpg" alt="step 2" width="156" height="90"></p>
<p align="left">In the dialog box that opens, click the <strong>Export for ActionScript</strong> option. Just leave the other options as they are, this will create a class named &quot;Circle&quot; for us to use in our code. I generally like to leave the class name the same as the movie clip for easy reference. Click <strong>OK</strong> to close this dialog box when you are finished.. </p>
<p align="center"><img src="http://flizash.com/images/place_on_stage/step3.jpg" alt="step 3" width="444" height="233"></p>
<p align="left">After hitting OK, you will likely see this warning:</p>
<p align="center"><img src="http://flizash.com/images/place_on_stage/step4.jpg" alt="step 4" width="363" height="164"> </p>
<p align="left">Just click <strong>OK</strong> here. Flash is just letting us know that it couldn&#8217;t find a class for &quot;Circle&quot;, so it will create one automatically. Next thing I have done is create a new layer to put our actionscript on. This is not a necessary step, but it&#8217;s just something a lot of us do help keep everything organized. Click inside of frame 1 of the actions layer to make sure that we add our actionscript to that frame. You can see below that frame 1 is selected. </p>
<p align="center"><img src="http://flizash.com/images/place_on_stage/step5.jpg" alt="step 5" width="216" height="63"></p>
<p align="left">Now open up your actions window. You can use the F9 key to open it as a shortcut if it&#8217;s not already open. Use the following actionscript code to place a circle on the stage.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> circle:Circle = <span style="color: #000000; font-weight: bold;">new</span> Circle<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
circle.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;
circle.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">10</span>;
addChild<span style="color: #66cc66;">&#40;</span>circle<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p align="left">A quick explanation of the code, line by line:</p>
<p align="left"><strong>Line 1</strong>: This line creates a new instance of the &quot;Circle&quot; class, and to keep it simple I called it &quot;circle&quot;. You could call this instance anything you want, so long as the class is &quot;Circle.&quot;</p>
<p align="left"><strong>Line 2</strong>:   This line sets the x property of the circle to 10, which places the circle 10 pixels from the left of the start of the stage.</p>
<p align="left"><strong>Line 3</strong>: This sets the y property of the circle to 10, placing it 10 pixels from the top of the stage.</p>
<p align="left"><strong>Line 4</strong>: This line adds the circle to the display list. It is this line of code that makes Flash render the circle. </p>
<p align="left">Press <strong>ctrl + enter</strong> to test your movie within Flash. This is what my movie looks like:</p>
<p align="center"><img src="http://flizash.com/images/place_on_stage/step6.jpg" alt="step 6" width="309" height="198"> </p>
<p align="left">And that&#8217;s all there is to it! Next time I&#8217;ll show you how to make this example interactive and bring an object onto the screen when a user clicks a button. Click below to download the source file for my movie to look at what I did if you are having problems. (Right-click -&gt; Save As) </p>
<p align="center"><!--adsense#468_orange--></p>
<p align="center"><a href="http://flizash.com/images/place_on_stage/place_on_stage.zip">Download Source</a>  </p>
]]></content:encoded>
			<wfw:commentRss>http://flizash.com/2007/11/07/placing-an-object-on-the-stage-using-actionscript-30/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.252 seconds -->
<!-- Cached page served by WP-Cache -->
