In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Optimize iteration for Particleの理解のため

Get Adobe Flash player
by UNDERCOVER 24 May 2009
/**
 * Copyright UNDERCOVER ( http://wonderfl.net/user/UNDERCOVER )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wEyB
 */

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    public class FlashTest extends Sprite {
        private var NUM_PARTICLE:int=1000;
        private var particles:Particle;

        public function FlashTest() {

            var prev:Particle=particles=new Particle();

            var  p:Particle

            for(var i:int=0;i<NUM_PARTICLE;i++){
                p=new Particle()
  
                prev.next=p
                prev=p;
            }
            stage.addEventListener(MouseEvent.CLICK,click)
        }
        private function click(e:MouseEvent):void{
            var p:Particle=particles;
            while ((p = p.next) != null) {
                //なにかする
            } 
        }

    }
}
class Particle{
    public var next:Particle;
    public function Particle(){
    }
}