AS3 particle effect

Discussion in 'Web Design and Development' started by phadam, Jul 15, 2009.

  1. phadam macrumors regular

    Joined:
    Jan 21, 2009
    #1
    Anybody know of any particle effect tutorials i can follow in as3??? I would like to use one as a background on my site but I can only seem to find as1 and as2 tutorials. Still a learning process for me :)

    here is a link to what i am looking for
    http://www.actionscript.org/resources/articles/125/1/Simple-Particle-Effect/Page1.html

    ive done some searching and found other useful tutorials but still no luck on the particle effect. thanks
     
  2. snickelfritz macrumors 65816

    snickelfritz

    Joined:
    Oct 24, 2003
    Location:
    Tucson AZ
    #2
    I followed the tutorial and changed the code to AS3.
    Works pretty well.

    frame1:
    Code:
    var xMin:int = 0;
    var xMax:int = 550;
    var yMin:int = 0;
    var yMax:int = 400;
    var minSize:int = 10;
    var maxSize:int = 50;
    var easeFactor:int = 10;
    
    var randomX:int = Math.random () * ( xMax - xMin ) + xMin;
    var randomY:int = Math.random () * ( yMax - yMin ) + yMin;
    var randomSize:int = Math.random () * ( maxSize - minSize ) + minSize;
    
    frame3:
    Code:
    var distance:int = Math.sqrt(Math.pow(this.x-randomX, 2)+Math.pow(this.y-randomY, 2));
    
    if (Math.abs(this.width-maxSize)>1)
    {
    	this.width += (randomSize-this.width)/2;
    	this.height += (randomSize-this.height)/2;
    }
    
    if (distance>1)
    {
    	this.x += (randomX-this.x)/easeFactor;
    	this.y += (randomY-this.y)/easeFactor;
    	gotoAndPlay(2);
    } else
    {
    	gotoAndPlay(1);
    }
    
     
  3. lucidmedia macrumors 6502a

    Joined:
    Oct 13, 2008
    Location:
    Wellington, New Zealand
    #3
    The book:

    Foundation Actionscript 3.0 Animation: Making Things Move! by Keith Peters

    has a nice chapter on writing particle systems.

    Also, it may be worth looking at things like Flint: http://flintparticles.org/
     
  4. phadam thread starter macrumors regular

    Joined:
    Jan 21, 2009
    #4
    awesome. works great. i may head down to the book store this weekend. I'll definitely check out that book by Keith Peters.

    Thanks guys. the site is really coming along. slowly but getting there :)
     
  5. Kelon macrumors member

    Joined:
    Jul 14, 2009
    Location:
    UK
    #5
    Yes, the book above is one of the best I've come across for focussed tutorials on making things move. It's by FriendsofED publishing. It's a bit dry and lots of maths, but the animation possibilities that open up are awesome. Some of my best work resulted form studying that book.
     

Share This Page