<?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: ActionScript 3.0 Particle Systems #5: Smoke Effect</title>
	<atom:link href="http://r3dux.org/2010/01/actionscript-3-0-particle-systems-5-smoke-effect/feed/" rel="self" type="application/rss+xml" />
	<link>http://r3dux.org/2010/01/actionscript-3-0-particle-systems-5-smoke-effect/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=actionscript-3-0-particle-systems-5-smoke-effect</link>
	<description>A number-pimping side project from the valleys in *NEW* upside-down flavour.</description>
	<lastBuildDate>Fri, 10 Feb 2012 13:11:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: r3dux</title>
		<link>http://r3dux.org/2010/01/actionscript-3-0-particle-systems-5-smoke-effect/#comment-4901</link>
		<dc:creator>r3dux</dc:creator>
		<pubDate>Thu, 11 Feb 2010 00:36:30 +0000</pubDate>
		<guid isPermaLink="false">http://r3dux.org/?p=1621#comment-4901</guid>
		<description>Hey Joel - thanks for your input.

It seems that a Sprite is pretty much a MovieClip without a timeline (although there are other static/dynamic property issues too, they don&#039;t come into play in this particular piece of code), so a Sprite makes more sense to use than a MC, and will indeed speed things up, but by a very small amount - but hey, it all counts!

I hadn&#039;t noticed the null reference was introduced when I recently updated the code to remove the particles as soon as they&#039;re entirely transparent or above the stage - I was just trying to eke out every bit of performance I knew how by removing particles from the stage as soon as I possibly could. 

The unintended side effect of this was that flash then tries to remove the particles twice:
- Once when they&#039;re transparent or above the stage (called from within the SmokeParticle Class), and
- Again when the particle limit gets rid of the oldest particle (i.e. array element 0) to add a new particle (called from the main flash file)

Hence the null pointer reference for any particle that has already been &quot;removed&quot; when the transparent/above remover kicked in from the updateParticle function.

If you comment out the &lt;b&gt;parent.removeChild(this);&lt;/b&gt; line in the ParticleDestructor function, normal service is resumed, but performance suffers because we&#039;re not eliminating the particle as soon as we possibly can.

I&#039;ll have a look at the code again this evening and either wrap the removeChild calls in some conditions, or add a SmokeParticle property to keep track of whether the particle&#039;s already been removed so hopefully we can keep our speed gain from nuking the particle early, but lose the null-pointer shenanigans :)

&lt;b&gt;Update&lt;/b&gt;: Done! </description>
		<content:encoded><![CDATA[<p>Hey Joel &#8211; thanks for your input.</p>
<p>It seems that a Sprite is pretty much a MovieClip without a timeline (although there are other static/dynamic property issues too, they don&#8217;t come into play in this particular piece of code), so a Sprite makes more sense to use than a MC, and will indeed speed things up, but by a very small amount &#8211; but hey, it all counts!</p>
<p>I hadn&#8217;t noticed the null reference was introduced when I recently updated the code to remove the particles as soon as they&#8217;re entirely transparent or above the stage &#8211; I was just trying to eke out every bit of performance I knew how by removing particles from the stage as soon as I possibly could. </p>
<p>The unintended side effect of this was that flash then tries to remove the particles twice:<br />
- Once when they&#8217;re transparent or above the stage (called from within the SmokeParticle Class), and<br />
- Again when the particle limit gets rid of the oldest particle (i.e. array element 0) to add a new particle (called from the main flash file)</p>
<p>Hence the null pointer reference for any particle that has already been &#8220;removed&#8221; when the transparent/above remover kicked in from the updateParticle function.</p>
<p>If you comment out the <b>parent.removeChild(this);</b> line in the ParticleDestructor function, normal service is resumed, but performance suffers because we&#8217;re not eliminating the particle as soon as we possibly can.</p>
<p>I&#8217;ll have a look at the code again this evening and either wrap the removeChild calls in some conditions, or add a SmokeParticle property to keep track of whether the particle&#8217;s already been removed so hopefully we can keep our speed gain from nuking the particle early, but lose the null-pointer shenanigans <img src='http://r3dux.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><b>Update</b>: Done!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://r3dux.org/2010/01/actionscript-3-0-particle-systems-5-smoke-effect/#comment-4895</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Wed, 10 Feb 2010 12:52:05 +0000</pubDate>
		<guid isPermaLink="false">http://r3dux.org/?p=1621#comment-4895</guid>
		<description>Thanks for sharing. Given my lack of experience I can&#039;t offer much to help speed up the animation, but I did notice you use a MovieClip for your canvas. Could you get by using a Sprite instead? Perhaps that&#039;s a negligible improvement, but I thought I&#039;d mention nonetheless. Also, the debug flash player throws a null reference error relating to particleDestructor() and addParticles().</description>
		<content:encoded><![CDATA[<p>Thanks for sharing. Given my lack of experience I can&#8217;t offer much to help speed up the animation, but I did notice you use a MovieClip for your canvas. Could you get by using a Sprite instead? Perhaps that&#8217;s a negligible improvement, but I thought I&#8217;d mention nonetheless. Also, the debug flash player throws a null reference error relating to particleDestructor() and addParticles().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ActionScript 3.0: Per-Pixel Collision Detection inna rub-a-dub Peggle Stylee &#124; r3dux.org</title>
		<link>http://r3dux.org/2010/01/actionscript-3-0-particle-systems-5-smoke-effect/#comment-4640</link>
		<dc:creator>ActionScript 3.0: Per-Pixel Collision Detection inna rub-a-dub Peggle Stylee &#124; r3dux.org</dc:creator>
		<pubDate>Sat, 23 Jan 2010 05:32:31 +0000</pubDate>
		<guid isPermaLink="false">http://r3dux.org/?p=1621#comment-4640</guid>
		<description>[...] project uses the FPSCounter class (which can be found here), but it&#8217;s not new so I&#8217;m not putting the source in this post. it is, of course, [...]</description>
		<content:encoded><![CDATA[<p>[...] project uses the FPSCounter class (which can be found here), but it&#8217;s not new so I&#8217;m not putting the source in this post. it is, of course, [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

