<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Throw a ball with a sling physics Flash tutorial</title>
	<atom:link href="http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Wed, 17 Mar 2010 22:10:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: This_Guy_is_a_Newbie_in_Flash</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-35208</link>
		<dc:creator>This_Guy_is_a_Newbie_in_Flash</dc:creator>
		<pubDate>Wed, 12 Sep 2007 02:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-35208</guid>
		<description>thank u very much

btw how can u make it launch when u let go of the
mouse button

again THANK U</description>
		<content:encoded><![CDATA[<p>thank u very much</p>
<p>btw how can u make it launch when u let go of the<br />
mouse button</p>
<p>again THANK U</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frederik J</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-30471</link>
		<dc:creator>Frederik J</dc:creator>
		<pubDate>Sun, 19 Aug 2007 08:02:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-30471</guid>
		<description>Yo need to go to your library. Right click on the slings, and press linkage. The you enable &quot;Export for Actionscript&quot;. Make sure you do it at both of them.</description>
		<content:encoded><![CDATA[<p>Yo need to go to your library. Right click on the slings, and press linkage. The you enable &#8220;Export for Actionscript&#8221;. Make sure you do it at both of them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cod</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-30394</link>
		<dc:creator>cod</dc:creator>
		<pubDate>Sat, 18 Aug 2007 13:04:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-30394</guid>
		<description>im having some problems please help me :D
in the first script    1.
      attachMovie(&quot;sling&quot;, &quot;sling_1&quot;, _root.getNextHighestDepth(), {_x:20, _y:200});
   2.
      attachMovie(&quot;sling&quot;, &quot;sling_2&quot;, _root.getNextHighestDepth(), {_x:480, _y:200});
   3.
      attachMovie(&quot;ball&quot;, &quot;ball&quot;, _root.getNextHighestDepth(), {_x:250, _y:100});
   4.
      _root.createEmptyMovieClip(&quot;elastic&quot;, _root.getNextHighestDepth());
   5.
      ball.onPress = function() {
   6.
          startDrag(this);
   7.
      };
   8.
      ball.onRelease = function() {
   9.
          stopDrag();
  10.
      };

its not working there is supposed to be 2 slings right but there is nothing but one and when i check the script it says script has no errors 


please help me im a newbie to flashbut i know the basics</description>
		<content:encoded><![CDATA[<p>im having some problems please help me :D<br />
in the first script    1.<br />
      attachMovie(&#8220;sling&#8221;, &#8220;sling_1&#8243;, _root.getNextHighestDepth(), {_x:20, _y:200});<br />
   2.<br />
      attachMovie(&#8220;sling&#8221;, &#8220;sling_2&#8243;, _root.getNextHighestDepth(), {_x:480, _y:200});<br />
   3.<br />
      attachMovie(&#8220;ball&#8221;, &#8220;ball&#8221;, _root.getNextHighestDepth(), {_x:250, _y:100});<br />
   4.<br />
      _root.createEmptyMovieClip(&#8220;elastic&#8221;, _root.getNextHighestDepth());<br />
   5.<br />
      ball.onPress = function() {<br />
   6.<br />
          startDrag(this);<br />
   7.<br />
      };<br />
   8.<br />
      ball.onRelease = function() {<br />
   9.<br />
          stopDrag();<br />
  10.<br />
      };</p>
<p>its not working there is supposed to be 2 slings right but there is nothing but one and when i check the script it says script has no errors </p>
<p>please help me im a newbie to flashbut i know the basics</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Throw a ball with a sling physics Flash tutorial: Part 2 by Kevin Ward at Emanuele Feronato</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-30058</link>
		<dc:creator>Throw a ball with a sling physics Flash tutorial: Part 2 by Kevin Ward at Emanuele Feronato</dc:creator>
		<pubDate>Thu, 16 Aug 2007 08:40:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-30058</guid>
		<description>[...] Only 2 days. That&#039;s how much time Kevin Ward needed to solve and publish the solution of the problem posted in Throw a ball with a sling physics Flash tutorial. [...]</description>
		<content:encoded><![CDATA[<p>[...] Only 2 days. That&#8217;s how much time Kevin Ward needed to solve and publish the solution of the problem posted in Throw a ball with a sling physics Flash tutorial. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Izy</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-29983</link>
		<dc:creator>Izy</dc:creator>
		<pubDate>Wed, 15 Aug 2007 15:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-29983</guid>
		<description>It looks like it doesn&#039;t print the plus sign.  I guess I&#039;ll have it to e-mail you.</description>
		<content:encoded><![CDATA[<p>It looks like it doesn&#8217;t print the plus sign.  I guess I&#8217;ll have it to e-mail you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Izy</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-29968</link>
		<dc:creator>Izy</dc:creator>
		<pubDate>Wed, 15 Aug 2007 13:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-29968</guid>
		<description>This one&#039;s really cool.

I think I have it figured out.

var ball:MovieClip = _root.attachMovie(&quot;ball&quot;, &quot;ball&quot;, 2, {_x:275, _y:100});
var elastic:MovieClip = _root.createEmptyMovieClip(&quot;elastic&quot;, 1);
var point1:MovieClip = _root.attachMovie(&quot;sling&quot;, &quot;point1&quot;, 3, {_x:100, _y:200});
var point2:MovieClip = _root.attachMovie(&quot;sling&quot;, &quot;point2&quot;, 4, {_x:450, _y:200});

var gravity = 0.1;

var angle1:Number = 0;

var angle2:Number = 0;

var radius:Number = 13.0; // Or whatever half the width of your ball is.

var released:Boolean = true;

var forced:Boolean = false;

var acc:Object = {x:0,y:0};
var vel:Object = {x:0,y:0};

_root.onMouseDown = function() {
	
	ball._x = _root._xmouse;
	ball._y = _root._ymouse;
	ball.startDrag();
	_root.released = false;
	vel.x = 0;
	vel.y = 0;
}

_root.onMouseUp = function() {
	
	ball.stopDrag();
	_root.released = true;
	
}

ball.onPress = function() {
	
	ball.startDrag();
	_root.released = false;
	vel.x = 0;
	vel.y = 0;
}

ball.onRelease = function() {
	
	ball.stopDrag();
	_root.released = true;
	
}

_root.onEnterFrame = function() {
	
	elastic.clear();
	elastic.lineStyle(5, 0x00EE00);
	
	if (released) {
		
		ball._x  = vel.x;
		ball._y  = vel.y;
		
	}
	
	if (ball._y &gt;= 187) {
		
		forced = true;
		
		var x1:Number = ball._x-point1._x;
		var y1:Number = ball._y-point1._y;
		
		var x2:Number = point2._x-ball._x;
		var y2:Number = point2._y-ball._y;
		
		var distance1:Number = Math.sqrt(x1*x1 y1*y1);
		var distance2:Number = Math.sqrt(x2*x2 y2*y2);
		
		_root.angle1 = Math.atan2(y1,x1);
		_root.angle2 = Math.atan2(y2,x2);
		
		var xOffset:Number = Math.cos(angle1 Math.PI/2)*radius;
		var yOffset:Number = Math.sin(angle1 Math.PI/2)*radius;
		
		var xOffset2:Number = Math.cos(angle2 Math.PI/2)*radius;
		var yOffset2:Number = Math.sin(angle2 Math.PI/2)*radius;
		
		elastic.moveTo(point1._x, point1._y);
		elastic.lineTo(ball._x xOffset, ball._y yOffset);
		
		elastic.moveTo(point2._x, point2._y);
		elastic.lineTo(ball._x xOffset2, ball._y yOffset2);
		
	}
	else {
		
		forced = false;
		elastic.moveTo(point1._x, point1._y);
		elastic.lineTo(point2._x, point2._y);
		
	}
	acc.x = 0;
	acc.y = 0;	
	acc.y = gravity;
	
	if (released &amp;&amp; forced) {
		
		acc.x  = distance1*Math.sin(angle2)/1000;
		acc.y  = -distance1*Math.cos(angle1)/1000;
		
		acc.x  = distance2*Math.sin(angle1)/1000;
		acc.y  = -distance2*Math.cos(angle2)/1000;
					
	}
	
	if (released) {
		
		vel.x  = acc.x;
		vel.y  = acc.y;
		
	}
	
}</description>
		<content:encoded><![CDATA[<p>This one&#8217;s really cool.</p>
<p>I think I have it figured out.</p>
<p>var ball:MovieClip = _root.attachMovie(&#8220;ball&#8221;, &#8220;ball&#8221;, 2, {_x:275, _y:100});<br />
var elastic:MovieClip = _root.createEmptyMovieClip(&#8220;elastic&#8221;, 1);<br />
var point1:MovieClip = _root.attachMovie(&#8220;sling&#8221;, &#8220;point1&#8243;, 3, {_x:100, _y:200});<br />
var point2:MovieClip = _root.attachMovie(&#8220;sling&#8221;, &#8220;point2&#8243;, 4, {_x:450, _y:200});</p>
<p>var gravity = 0.1;</p>
<p>var angle1:Number = 0;</p>
<p>var angle2:Number = 0;</p>
<p>var radius:Number = 13.0; // Or whatever half the width of your ball is.</p>
<p>var released:Boolean = true;</p>
<p>var forced:Boolean = false;</p>
<p>var acc:Object = {x:0,y:0};<br />
var vel:Object = {x:0,y:0};</p>
<p>_root.onMouseDown = function() {</p>
<p>	ball._x = _root._xmouse;<br />
	ball._y = _root._ymouse;<br />
	ball.startDrag();<br />
	_root.released = false;<br />
	vel.x = 0;<br />
	vel.y = 0;<br />
}</p>
<p>_root.onMouseUp = function() {</p>
<p>	ball.stopDrag();<br />
	_root.released = true;</p>
<p>}</p>
<p>ball.onPress = function() {</p>
<p>	ball.startDrag();<br />
	_root.released = false;<br />
	vel.x = 0;<br />
	vel.y = 0;<br />
}</p>
<p>ball.onRelease = function() {</p>
<p>	ball.stopDrag();<br />
	_root.released = true;</p>
<p>}</p>
<p>_root.onEnterFrame = function() {</p>
<p>	elastic.clear();<br />
	elastic.lineStyle(5, 0&#215;00EE00);</p>
<p>	if (released) {</p>
<p>		ball._x  = vel.x;<br />
		ball._y  = vel.y;</p>
<p>	}</p>
<p>	if (ball._y &gt;= 187) {</p>
<p>		forced = true;</p>
<p>		var x1:Number = ball._x-point1._x;<br />
		var y1:Number = ball._y-point1._y;</p>
<p>		var x2:Number = point2._x-ball._x;<br />
		var y2:Number = point2._y-ball._y;</p>
<p>		var distance1:Number = Math.sqrt(x1*x1 y1*y1);<br />
		var distance2:Number = Math.sqrt(x2*x2 y2*y2);</p>
<p>		_root.angle1 = Math.atan2(y1,x1);<br />
		_root.angle2 = Math.atan2(y2,x2);</p>
<p>		var xOffset:Number = Math.cos(angle1 Math.PI/2)*radius;<br />
		var yOffset:Number = Math.sin(angle1 Math.PI/2)*radius;</p>
<p>		var xOffset2:Number = Math.cos(angle2 Math.PI/2)*radius;<br />
		var yOffset2:Number = Math.sin(angle2 Math.PI/2)*radius;</p>
<p>		elastic.moveTo(point1._x, point1._y);<br />
		elastic.lineTo(ball._x xOffset, ball._y yOffset);</p>
<p>		elastic.moveTo(point2._x, point2._y);<br />
		elastic.lineTo(ball._x xOffset2, ball._y yOffset2);</p>
<p>	}<br />
	else {</p>
<p>		forced = false;<br />
		elastic.moveTo(point1._x, point1._y);<br />
		elastic.lineTo(point2._x, point2._y);</p>
<p>	}<br />
	acc.x = 0;<br />
	acc.y = 0;<br />
	acc.y = gravity;</p>
<p>	if (released &amp;&amp; forced) {</p>
<p>		acc.x  = distance1*Math.sin(angle2)/1000;<br />
		acc.y  = -distance1*Math.cos(angle1)/1000;</p>
<p>		acc.x  = distance2*Math.sin(angle1)/1000;<br />
		acc.y  = -distance2*Math.cos(angle2)/1000;</p>
<p>	}</p>
<p>	if (released) {</p>
<p>		vel.x  = acc.x;<br />
		vel.y  = acc.y;</p>
<p>	}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: squareCircleZ &#187; More game math</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-29898</link>
		<dc:creator>squareCircleZ &#187; More game math</dc:creator>
		<pubDate>Wed, 15 Aug 2007 02:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-29898</guid>
		<description>[...] One guy has started on his competition entry entitled Throw a ball with a sling. The article includes a tutorial on how he is incorporating mathematics into his game. [...]</description>
		<content:encoded><![CDATA[<p>[...] One guy has started on his competition entry entitled Throw a ball with a sling. The article includes a tutorial on how he is incorporating mathematics into his game. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Emanuele Feronato</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-29830</link>
		<dc:creator>Emanuele Feronato</dc:creator>
		<pubDate>Tue, 14 Aug 2007 15:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-29830</guid>
		<description>Fixed

Thank you.</description>
		<content:encoded><![CDATA[<p>Fixed</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dean</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-29814</link>
		<dc:creator>Dean</dc:creator>
		<pubDate>Tue, 14 Aug 2007 13:34:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-29814</guid>
		<description>The download link is broken.</description>
		<content:encoded><![CDATA[<p>The download link is broken.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Owen</title>
		<link>http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/comment-page-1/#comment-29651</link>
		<dc:creator>Adam Owen</dc:creator>
		<pubDate>Mon, 13 Aug 2007 15:27:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/2007/08/13/throw-a-ball-with-a-sling-physics-flash-tutorial/#comment-29651</guid>
		<description>Another awesome tutorial!

I&#039;ve always wondered how this was done after playing the slingstar game on teagames. Their rope bends round the ball but I think your solution looks fine as it is.

Looking forward to seeing how to fling the ball!

Thanks!</description>
		<content:encoded><![CDATA[<p>Another awesome tutorial!</p>
<p>I&#8217;ve always wondered how this was done after playing the slingstar game on teagames. Their rope bends round the ball but I think your solution looks fine as it is.</p>
<p>Looking forward to seeing how to fling the ball!</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
