Optimize iteration for Particleの理解のため
/**
* 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(){
}
}