<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">
<channel><title><![CDATA[ActionScript.org Flash, Flex and ActionScript Resources - Comments for article: A simple particle system using Actionscript 3]]></title><link>http://www.actionscript.org/resources</link><description /><language>en-us</language><copyright><![CDATA[http://www.actionscript.org/resources]]></copyright><generator>N/A</generator><webMaster>general.redirect@gmail.com</webMaster><lastBuildDate>Tue, 24 Nov 2009 15:13:29 CST</lastBuildDate><ttl>20</ttl><item><title><![CDATA[Comment #1]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3206</link><description><![CDATA[Hi, your tutorial was to be my first foray into the strange and alien world of AS3. I have coded in AS2 years now and can see applications in AS2 like Neo sees the Matrix. Sort of.

Anyway, I attempted to follow your instructions, but every time I attempted to test and compile, the following errors were given:

1. [as] should not be there.
2. The class 'Ball' must subclass 'flash.display.MovieClip'
3. The protected attribute can only be used in class property definitions.

I have copied your code verbatim into 'Particle.as', 'Ball.as' and frame 1 of 'main.fla'. Where am I going wrong?<br/><br/>
(Comment posted by Alexander at 1:26 pm, Thu 17th May 2007)]]></description><author>no@spam.com (Alexander)</author><pubDate><![CDATA[Thu, 17 May 2007 13:26:53 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3206</guid></item><item><title><![CDATA[Comment #2]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3302</link><description><![CDATA[1. That's an error in the article that was made upon publishing.

2. Odd, since it extends Particle and  particle extends flash.display.MovieClip it should work fine.  Are you using Flash CS3's compiler or the flex2 commandline compiler?

3.  Put the property by all the rest up at the top of the class.  The tutorial isn't sequential in this case, sorry bout the confusion.

-Sam  <br/><br/>
(Comment posted by Sam Coles at 8:12 am, Mon 21st May 2007)]]></description><author>no@spam.com (Sam Coles)</author><pubDate><![CDATA[Mon, 21 May 2007 08:12:57 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3302</guid></item><item><title><![CDATA[Comment #3]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3315</link><description><![CDATA[You should remove the [as] from your code, it's a Typo from placing the code in the post.

And it sounds like you are importing the Particle class somwhere… Have you defined it as the document class on accident? If you omit the [as] and make sure all your files (the fla, Particle, and Ball class) are in the same folder you should be good to go, it worked for me.<br/><br/>
(Comment posted by Collin Reisdorf at 5:09 pm, Mon 21st May 2007)]]></description><author>no@spam.com (Collin Reisdorf)</author><pubDate><![CDATA[Mon, 21 May 2007 17:09:18 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3315</guid></item><item><title><![CDATA[Comment #4]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3422</link><description><![CDATA[Is there a source file for this. I am intermediate at best in fla. I got lost trying to figure out where the first half of the .as is to be stored for import in the first frame.

Thank You<br/><br/>
(Comment posted by Jeff Baker at 1:15 pm, Thu 24th May 2007)]]></description><author>no@spam.com (Jeff Baker)</author><pubDate><![CDATA[Thu, 24 May 2007 13:15:46 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3422</guid></item><item><title><![CDATA[Comment #5]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3477</link><description><![CDATA[I'm also having an error compiling. I have three files: test.fla, particle.as and ball.as - all are saved in the same directory, but when I compile test.fla I get this error:

1136: Incorrect number of arguments.  Expected 0.<br/><br/>
(Comment posted by efnx at 2:58 pm, Sat 26th May 2007)]]></description><author>no@spam.com (efnx)</author><pubDate><![CDATA[Sat, 26 May 2007 14:58:54 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3477</guid></item><item><title><![CDATA[Comment #6]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3542</link><description><![CDATA[ partcle coding is great<br/><br/>
(Comment posted by dushyant at 6:56 am, Tue 29th May 2007)]]></description><author>no@spam.com (dushyant)</author><pubDate><![CDATA[Tue, 29 May 2007 06:56:54 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment3542</guid></item><item><title><![CDATA[Comment #7]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment5226</link><description><![CDATA[Hi i'm new to AS3, can you tell me what does the $ sign means before the argument?

public function Ball($position:Point, $vector:Point, $gravity:int, $friction:Number)

nice tutorial

regards
<br/><br/>
(Comment posted by eka at 9:00 am, Tue 7th Aug 2007)]]></description><author>no@spam.com (eka)</author><pubDate><![CDATA[Tue, 07 Aug 2007 09:00:17 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment5226</guid></item><item><title><![CDATA[Comment #8]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7019</link><description><![CDATA[ArgumentError: Error #1063: Argument count mismatch on Particle$iinit(). Expected 4, got 0.<br/><br/>
(Comment posted by Dave at 1:30 pm, Wed 24th Oct 2007)]]></description><author>no@spam.com (Dave)</author><pubDate><![CDATA[Wed, 24 Oct 2007 13:30:35 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7019</guid></item><item><title><![CDATA[Comment #9]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7027</link><description><![CDATA[ I get the following error any light on this ???
ArgumentError: Error #1063: Argument count mismatch on Particle$iinit(). Expected 4, got 0.<br/><br/>
(Comment posted by Dave at 2:38 pm, Wed 24th Oct 2007)]]></description><author>no@spam.com (Dave)</author><pubDate><![CDATA[Wed, 24 Oct 2007 14:38:27 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7027</guid></item><item><title><![CDATA[Comment #10]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7116</link><description><![CDATA[It's no wonder everyone is having trouble with this - its badly written and pieces are given in the wrong order.

After a bit of fooling though, it works.<br/><br/>
(Comment posted by Melon at 7:58 am, Sun 28th Oct 2007)]]></description><author>no@spam.com (Melon)</author><pubDate><![CDATA[Sun, 28 Oct 2007 07:58:04 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7116</guid></item><item><title><![CDATA[Comment #11]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7657</link><description><![CDATA[It is a bit confusing with the out-of-sequence code snippets and vague instructions on where to actually paste the code snippets to, but unlike many "tutorials" it makes you think about what you're doing instead of just blindly cut-and-pasting and running the finished  app.
<br/><br/>
(Comment posted by steve at 8:44 pm, Wed 21st Nov 2007)]]></description><author>no@spam.com (steve)</author><pubDate><![CDATA[Wed, 21 Nov 2007 20:44:27 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment7657</guid></item><item><title><![CDATA[Comment #12]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment8144</link><description><![CDATA[This is very cool. Will you mind if I demonstrated this tutorial in a video format? I think a little "show-me" might help others a bit.<br/><br/>
(Comment posted by Eric at 10:05 pm, Mon 10th Dec 2007)]]></description><author>no@spam.com (Eric)</author><pubDate><![CDATA[Mon, 10 Dec 2007 22:05:02 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment8144</guid></item><item><title><![CDATA[Comment #13]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment11825</link><description><![CDATA[Whats so hard to understand? Its OOP the first 6 boxes go into Particle.as file the next 3 go into another Ball.as file remove the obvious [as] as its not part of the code. The rest go into your fla file called what ever you want it to be.fla for example particle.fla or test.fla, I will say that the only part that really is out of place is when you create the ball object itself in the fla file which is something that you put in your library and give it the same class name as the Ball.as file so "Ball".  Someone asked what the $ meant in front of the variables having a quick search yielded this
http://www.actionscript.org/forums/showthread.php3?t=91412

I have to say that this article did a very good job on explaining OOP concepts.<br/><br/>
(Comment posted by Adam at 9:56 pm, Thu 14th Aug 2008)]]></description><author>no@spam.com (Adam)</author><pubDate><![CDATA[Thu, 14 Aug 2008 21:56:20 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment11825</guid></item><item><title><![CDATA[Comment #14]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment11826</link><description><![CDATA[I also need to add that the protected var update_i:Timer; needs to be outside the public function Particle up with the private vars oh and as I looked at the code better I realized that the $ is being used to seperate the 2 types of variables as position = $position (so instead of using a different name).<br/><br/>
(Comment posted by Adam at 10:47 pm, Thu 14th Aug 2008)]]></description><author>no@spam.com (Adam)</author><pubDate><![CDATA[Thu, 14 Aug 2008 22:47:41 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment11826</guid></item><item><title><![CDATA[Comment #15]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12102</link><description><![CDATA[This a great little system :)
I was able to get it working following the comments left by Adam ^
It could really use the some function to remove each tBall when a condition is met (say when they reach x pos) Without it the frame rate starts to drop and memory usage increases.

This is fine normally but if you start to tweak things or tween the ball mc it can get really sluggish.
I tried myself to remove them but my AS skills are lacking ;)<br/><br/>
(Comment posted by Jim at 12:23 pm, Sat 11th Oct 2008)]]></description><author>no@spam.com (Jim)</author><pubDate><![CDATA[Sat, 11 Oct 2008 12:23:57 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12102</guid></item><item><title><![CDATA[Comment #16]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12275</link><description><![CDATA[I got it to work also, but I had to create a "movie clip" symbol called Ball with "Export for ActionScript" checked and Class: Ball

once this was done I had to debug, and fixed it by moving the line:   protected var update_i:Timer; 
before the Particle function in the Particle.as file.    You do not have to do anything to  import the as files they are automatically called as long as the filename matches
example:  var tBall:Ball = new Ball(new Point(mouseX, mouseY)......
"new Ball" actually calls the file Ball.as if it exists to find it's class deifintion.

Hopes this helps others cause it took me about 30-45 minutes to figure it out.  I'm quite a noob at this, but have been coding in other languages for a long time.<br/><br/>
(Comment posted by RKaneKnight at 11:11 am, Fri 14th Nov 2008)]]></description><author>no@spam.com (RKaneKnight)</author><pubDate><![CDATA[Fri, 14 Nov 2008 11:11:10 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12275</guid></item><item><title><![CDATA[Comment #17]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12330</link><description><![CDATA[First of all: great class! I used this to creae some simple snow animation and it turned out great.

There is just one but... performance.
If I keep it running for more than 10 seconds it slows down considerably and after a while it practically comes to a halt. I'm guessing this is because of the insane amount of eventListeners that are added. It's only 1 listener per particle, but since this script adds about 40 particles per second (in my case even 100 per second, with a 10ms interval) it gets very heavy, very fast.

How can I solve this in a nice and clean way? When you remove an instance do the eventListeners get removed too? In that case adding a __descruct function that removes the child would be enough, wouldn't it?

Any thoughts on this?<br/><br/>
(Comment posted by Wouter at 8:12 am, Fri 28th Nov 2008)]]></description><author>no@spam.com (Wouter)</author><pubDate><![CDATA[Fri, 28 Nov 2008 08:12:45 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12330</guid></item><item><title><![CDATA[Comment #18]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12389</link><description><![CDATA[roflcopters I'm gonna make a video tutorial on how to do this better. Nice start though.<br/><br/>
(Comment posted by Jesse Nicholson at 11:07 pm, Tue 9th Dec 2008)]]></description><author>no@spam.com (Jesse Nicholson)</author><pubDate><![CDATA[Tue, 09 Dec 2008 23:07:22 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12389</guid></item><item><title><![CDATA[Comment #19]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12517</link><description><![CDATA[Ok guys, it is really simple.  

Take out the [as].  
Then, pay attention to this line:  update_i.addEventListener(TimerEvent, setPosition, false, 0, true);
        }

It should look like this update_i.addEventListener(TimerEvent.TIMER, setPosition, false, 0, true);
        }
Other than that, do exactly as he says.  
Stop giving him a hard time.  Be thankful you learned something.<br/><br/>
(Comment posted by Christian at 10:21 pm, Fri 16th Jan 2009)]]></description><author>no@spam.com (Christian)</author><pubDate><![CDATA[Fri, 16 Jan 2009 22:21:20 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12517</guid></item><item><title><![CDATA[Comment #20]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12548</link><description><![CDATA[Great tutorial! If your having problems read the replies by Adam & Christian and that should correct any errors.  Final product looks great!<br/><br/>
(Comment posted by Jim at 12:53 pm, Fri 23rd Jan 2009)]]></description><author>no@spam.com (Jim)</author><pubDate><![CDATA[Fri, 23 Jan 2009 12:53:31 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12548</guid></item><item><title><![CDATA[Comment #21]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12610</link><description><![CDATA[Wouter,

I know I'm a little late, but I figured I would post this in response to your message.

The reason flash is slowing down and then coming to a halt (and this is just my guess) is because the author of the script didn't write a cleanup function to remove any particles that have fallen below the viewable area of the stage.

This can be accomplished by adding an event listener for each ball that is thrown and testing to see whether or not the ball has exceeded the maximum height of the stage. When this happens, simply remove the clip using the removeChild() function.

I used (please pardon my naming conventions for variables, I rewrote the script):

// When the ball is created..
jBall.addEventListener(Event.ENTER_FRAME, eCheckForDestruction);

// And the event listener..
function eCheckForDestruction(oEvent1:Event) {
	var jBall:Ball = oEvent1.target as Ball;
	
	if (jBall.y > stage.stageHeight) {
		jBall.removeEventListener(Event.ENTER_FRAME, eCheckForDestruction);
		removeChild(jBall);
	}
}<br/><br/>
(Comment posted by Gerald Spooner at 4:14 pm, Fri 6th Feb 2009)]]></description><author>no@spam.com (Gerald Spooner)</author><pubDate><![CDATA[Fri, 06 Feb 2009 16:14:54 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12610</guid></item><item><title><![CDATA[Comment #22]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12668</link><description><![CDATA[Wow!..excellent tutorial!..best ive found so far!..good job! :D<br/><br/>
(Comment posted by Seth at 2:45 pm, Thu 19th Feb 2009)]]></description><author>no@spam.com (Seth)</author><pubDate><![CDATA[Thu, 19 Feb 2009 14:45:44 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12668</guid></item><item><title><![CDATA[Comment #23]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12676</link><description><![CDATA[The debug player gives me this indefinitely...

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Particle/kill()
	at Sparkler/moveSparkler()
	at Sparkler/_init()
	at Sparkler()
	at partssource_fla::MainTimeline/addSpark()
	at flash.utils::Timer/_timerDispatch()
	at flash.utils::Timer/tick()<br/><br/>
(Comment posted by Jason at 1:36 pm, Fri 20th Feb 2009)]]></description><author>no@spam.com (Jason)</author><pubDate><![CDATA[Fri, 20 Feb 2009 13:36:13 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12676</guid></item><item><title><![CDATA[Comment #24]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12678</link><description><![CDATA[regarding the previous comment that uses an enter frame.  Using an enter frame with a timer event is redundant and only uses more power.  The proper as 3.0 method would be to push the instances in an array and then loop through that array and removeChild(arrayChild[i]);  Doing this will reduce your cpu to 8% and be very stable.

Cheers  
Ben<br/><br/>
(Comment posted by Ben at 3:16 pm, Fri 20th Feb 2009)]]></description><author>no@spam.com (Ben)</author><pubDate><![CDATA[Fri, 20 Feb 2009 15:16:49 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12678</guid></item><item><title><![CDATA[Comment #25]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12718</link><description><![CDATA[function throwBall($evt:TimerEvent):void{
			var tBall:Ball = new Ball(new Point(mouseX, mouseY), new Point((Math.random()-Math.random())*5, -Math.random()*8), gravity, friction);
					addChild(tBall);
					}




getting 1046 type was not found... can anyone help?<br/><br/>
(Comment posted by Patrick at 11:59 am, Tue 3rd Mar 2009)]]></description><author>no@spam.com (Patrick)</author><pubDate><![CDATA[Tue, 03 Mar 2009 11:59:41 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12718</guid></item><item><title><![CDATA[Comment #26]]></title><link>http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12793</link><description><![CDATA[Hmmm..... this looks very strange. Doesn't "$" mean it's a constant and it never changes or something? I am kinda like Eka, my eyes are crossin'. 8)<br/><br/>
(Comment posted by Jamster at 4:33 pm, Sun 22nd Mar 2009)]]></description><author>no@spam.com (Jamster)</author><pubDate><![CDATA[Sun, 22 Mar 2009 16:33:57 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/607/1/A-simple-particle-system-using-Actionscript-3/Page1.html#Comment12793</guid></item></channel></rss>