class CADeepField extends MovieClip { public var BITS = 200; public var RULESET = 30; public var BITSIZE = 5; public var depth:Number; public var dx:Number; public var dy:Number; public var cnt:Number; public var cellrow:String; public var cells:Array; public var txtRuleset:TextField; public var canvas:MovieClip; function onLoad() { cells = new Array(); dx = 0; dy = 0; depth = 0; cnt = 0; // set single seed row initRow(); initialize(); drawCellRow(); this.onKeyDown = function() { switch (Key.getCode()) { case 65: // a initialize(); drawCellRow(); break; case 66: // b applyRule(); drawCellRow(); break; case 67: // c initialize(); setRuleSet(random(256)); drawCellRow(); break; default: // trace("Key.getCode: "+Key.getCode()); break; } } Key.addListener(this); } function onMouseDown() { initialize(); } function initialize() { // remove old cells while (cells.length>0) { var ca = cells.pop(); ca.onEnterFrame = function() { if (this._alpha>0) { this._alpha-=this.da*2+5; } else { this.removeMovieClip(); } } } dx = 0; dy = 0; cnt = 0; setRuleSet(30); initRow(); } public function initRow() { cellrow = ""; for (var i=0;i> ruleNumber; var lsb = String(ruleOutcome%2); newrow += lsb; } // set new row cellrow = newrow; } public function setRuleSet(R:Number) { RULESET = R; txtRuleset.text = String(R); drawRuleSet(); } public function drawRuleSet() { for (var i=0;i<8;i++) { var nombre = "rlBox"+i; var init = {_x:i*40-160,_y:-50,val:i,rule:RULESET}; var neo = this.attachMovie("ruleBox",nombre,10000+i,init); } } }