<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: More Motion (Gravity)</title>
	<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/</link>
	<description>A digital supplement for the O'Reilly book</description>
	<pubDate>Tue, 07 Sep 2010 07:57:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Shaun</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3708</link>
		<dc:creator>Shaun</dc:creator>
		<pubDate>Tue, 01 Sep 2009 13:24:03 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3708</guid>
		<description>Hi,

The book is great, so thanks  for all of your hard work. I am trying to create a football game but am having difficulty with the z-axis. Could this be adjusted to include a z-axis or am I better off using a completely different method? 

Many thanks

Shaun</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>The book is great, so thanks  for all of your hard work. I am trying to create a football game but am having difficulty with the z-axis. Could this be adjusted to include a z-axis or am I better off using a completely different method? </p>
<p>Many thanks</p>
<p>Shaun</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jesse</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3490</link>
		<dc:creator>jesse</dc:creator>
		<pubDate>Fri, 07 Aug 2009 17:07:25 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3490</guid>
		<description>I am working on a side scroller and i would like to know how i can get my sprite to bounc off an enemy after he dies</description>
		<content:encoded><![CDATA[<p>I am working on a side scroller and i would like to know how i can get my sprite to bounc off an enemy after he dies</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3036</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Thu, 28 May 2009 13:54:39 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3036</guid>
		<description>Rich,
Thank you for taking the time to clear that up for me I do appreciate it. This motion issue has lead me to another question.  What happens when the ball leaves the stage? What I mean is what stops the looping or does it just continue running until the swf is closed? My guess is that since I am not getting some kind of stack error the loop has stopped, and what stopped it was that when the object left the stage it was no longer triggering the enter frame event.

Thanks again

Bob</description>
		<content:encoded><![CDATA[<p>Rich,<br />
Thank you for taking the time to clear that up for me I do appreciate it. This motion issue has lead me to another question.  What happens when the ball leaves the stage? What I mean is what stops the looping or does it just continue running until the swf is closed? My guess is that since I am not getting some kind of stack error the loop has stopped, and what stopped it was that when the object left the stage it was no longer triggering the enter frame event.</p>
<p>Thanks again</p>
<p>Bob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3025</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Wed, 27 May 2009 20:36:42 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3025</guid>
		<description>@Bob, the book was designed not to rely on classes. All the other books we knew about started off right away with classes and contributed to the intimidation factor of AS3. We wanted to emphasize that you could still accomplish a lot by using the timeline. At the same time, classes are really useful and important and are where you should aspire to be when your comfort level grows. AS3 takes several leaps forward when you start using OOP.

So, we introduced syntax and extreme changes (events and display list) in the timeline and then introduced classes in Chapter 6. From that point on, classes will become a bigger part of your workflow. Syntax will still be introduced in isolated snippets of timeline code, so you can concentrate on the subject at hand. Then classes will be used for additional examples. 

In your case, the reason you need to use &lt;span class="inlineas"&gt;this&lt;/span&gt; instead of &lt;span class="inlineas"&gt;ball&lt;/span&gt; is because you're making references while inside the class. The first snippet in your comment creates an instance of the class in the timeline. In THAT script, you'll use &lt;span class="inlineas"&gt;ball&lt;/span&gt; to refer to the ball. Inside the class, however, the code allows the ball to behave autonomously by referring to itself. If you used the reference &lt;span class="inlineas"&gt;ball&lt;/span&gt;, the class wouldn't understand because &lt;span class="inlineas"&gt;ball&lt;/span&gt; isn't defined anywhere that the class knows about.

Using &lt;span class="inlineas"&gt;ball&lt;/span&gt; inside the class would be like referring to yourself in the third person instead of using the pronoun "me." You can control your own behavior by updating your own x and y. Your parent can create you by saying "new", and they can direct you by name.x. If you said name.x, however, someone else would have to be in the room with you and have the same name to get any result. 

Looking over your class, ask yourself where &lt;span class="inlineas"&gt;ball&lt;/span&gt; is defined. The answer is, nowhere. Instead, it's defined in the timeline, where the very instance your analyzing was created. There are two scopes: timeline and class, and you have to know what you're referring to.

I hope this makes sense.</description>
		<content:encoded><![CDATA[<p>@Bob, the book was designed not to rely on classes. All the other books we knew about started off right away with classes and contributed to the intimidation factor of AS3. We wanted to emphasize that you could still accomplish a lot by using the timeline. At the same time, classes are really useful and important and are where you should aspire to be when your comfort level grows. AS3 takes several leaps forward when you start using OOP.</p>
<p>So, we introduced syntax and extreme changes (events and display list) in the timeline and then introduced classes in Chapter 6. From that point on, classes will become a bigger part of your workflow. Syntax will still be introduced in isolated snippets of timeline code, so you can concentrate on the subject at hand. Then classes will be used for additional examples. </p>
<p>In your case, the reason you need to use <span class="inlineas">this</span> instead of <span class="inlineas">ball</span> is because you&#8217;re making references while inside the class. The first snippet in your comment creates an instance of the class in the timeline. In THAT script, you&#8217;ll use <span class="inlineas">ball</span> to refer to the ball. Inside the class, however, the code allows the ball to behave autonomously by referring to itself. If you used the reference <span class="inlineas">ball</span>, the class wouldn&#8217;t understand because <span class="inlineas">ball</span> isn&#8217;t defined anywhere that the class knows about.</p>
<p>Using <span class="inlineas">ball</span> inside the class would be like referring to yourself in the third person instead of using the pronoun &#8220;me.&#8221; You can control your own behavior by updating your own x and y. Your parent can create you by saying &#8220;new&#8221;, and they can direct you by name.x. If you said name.x, however, someone else would have to be in the room with you and have the same name to get any result. </p>
<p>Looking over your class, ask yourself where <span class="inlineas">ball</span> is defined. The answer is, nowhere. Instead, it&#8217;s defined in the timeline, where the very instance your analyzing was created. There are two scopes: timeline and class, and you have to know what you&#8217;re referring to.</p>
<p>I hope this makes sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3024</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Wed, 27 May 2009 20:13:32 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-3024</guid>
		<description>I am working my way through your book and  like most of the others, find it an excellent resource.  I have a question about chapter 7 velocity and acceleration. I had some trouble until I realized that you had switched back to the main timeline frame one to run the acceleration code. It seemed strange to me that we would take a step back from OOP as started in ch 6 I am guessing it was for simplicy's sake.  At any rate I attempted to convert the velocity example into a class based example and eventually got it to work  but I do not understand exactly why it works

This is on frame one of the fla

&lt;pre class="code"&gt;
var ball:MovieClip = new Ball();
addChild(ball);
&lt;/pre&gt;

and this is what I created as Ball.as

&lt;pre class="code"&gt;
//Ball.as
package {
   
   import flash.display.MovieClip;
   import flash.events.*;
   
   public class Ball extends MovieClip{
      
      
      public var xVel:Number = 4;
      public var yVel:Number = 4;
      public var xAcc:Number = 1;
      public var yAcc:Number = 1;
      
      public function Ball() {
         this.x = this.y = 100;
         addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
      }
      
      function onLoop(evt:Event):void {
         this.x  = xVel;
         this.y  = yVel;
         
         xVel  = xAcc;
         yVel  = yAcc;
      }
   }
}
&lt;/pre&gt;

what I do not understand is why I had to change ball.x within the onLoop function to this.x in order to make it work.  I would appreciate your comments.

Thank You</description>
		<content:encoded><![CDATA[<p>I am working my way through your book and  like most of the others, find it an excellent resource.  I have a question about chapter 7 velocity and acceleration. I had some trouble until I realized that you had switched back to the main timeline frame one to run the acceleration code. It seemed strange to me that we would take a step back from OOP as started in ch 6 I am guessing it was for simplicy&#8217;s sake.  At any rate I attempted to convert the velocity example into a class based example and eventually got it to work  but I do not understand exactly why it works</p>
<p>This is on frame one of the fla</p>
<pre class="code">
var ball:MovieClip = new Ball();
addChild(ball);
</pre>
<p>and this is what I created as Ball.as</p>
<pre class="code">
//Ball.as
package {

   import flash.display.MovieClip;
   import flash.events.*;

   public class Ball extends MovieClip{

      public var xVel:Number = 4;
      public var yVel:Number = 4;
      public var xAcc:Number = 1;
      public var yAcc:Number = 1;

      public function Ball() {
         this.x = this.y = 100;
         addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
      }

      function onLoop(evt:Event):void {
         this.x  = xVel;
         this.y  = yVel;

         xVel  = xAcc;
         yVel  = yAcc;
      }
   }
}
</pre>
<p>what I do not understand is why I had to change ball.x within the onLoop function to this.x in order to make it work.  I would appreciate your comments.</p>
<p>Thank You</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-1710</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sun, 11 Jan 2009 22:22:20 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-1710</guid>
		<description>Thanks for the post. A little addition: if something bounces off a wall, you check whether the position is beyond that of the wall, and if it does: invert direction and set the position to that of the wall. I think it's more accurate if you'd set the position to the same distance that it was beyond the wall. For example, if the wall was at 390 and the object is at 395, i'd set it to 385 (instead of 390)</description>
		<content:encoded><![CDATA[<p>Thanks for the post. A little addition: if something bounces off a wall, you check whether the position is beyond that of the wall, and if it does: invert direction and set the position to that of the wall. I think it&#8217;s more accurate if you&#8217;d set the position to the same distance that it was beyond the wall. For example, if the wall was at 390 and the object is at 395, i&#8217;d set it to 385 (instead of 390)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luuk</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-1670</link>
		<dc:creator>Luuk</dc:creator>
		<pubDate>Tue, 06 Jan 2009 12:23:48 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-1670</guid>
		<description>This is greatt.
I hope more tutorials will be posted.</description>
		<content:encoded><![CDATA[<p>This is greatt.<br />
I hope more tutorials will be posted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonas</title>
		<link>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-1413</link>
		<dc:creator>Jonas</dc:creator>
		<pubDate>Wed, 10 Dec 2008 14:24:13 +0000</pubDate>
		<guid>http://www.learningactionscript3.com/2008/01/28/more-motion-gravity/#comment-1413</guid>
		<description>Very good tutorial</description>
		<content:encoded><![CDATA[<p>Very good tutorial</p>
]]></content:encoded>
	</item>
</channel>
</rss>
