How to calculate piCross row and column values
So you are making a piCross clone and are at the point where you need to display the row and column information. Here’s a quick example of how it’s done. Just adapt it to your project.
package {
import flash.display.Sprite;
import flash.text.TextField;
public class temp extends Sprite
{
public var tf:TextField = new TextField();
public var a:Array = new Array();
public function temp()
{
var fa:Array = new Array();
var st:String = new String();
a = [1,0,1,1,1,0,1,1,1,0,1,1,1,0,1];
addChild(tf);
fa = aGetRow(a);
for(var i:int = 1; i<fa[0]+1;i++){
st = st + String(fa[i]) + " ";
}
tf.text = st;
}
public function aGetRow(rArray:Array):Array{
var ta:Array = new Array(); //temp array
var tp:int = 0; //holds the temp array position
var spos:int = 0; //start position
var cnt:int = 0; //size of each section
while(spos < 15){ //max grid length is 15
if(rArray[spos]==1){ //found start of a section
while(rArray[spos]==1){ //count how many are in current section
cnt++; //inc the current section counter
spos++; //inc the main array postion
}
ta[tp+1] = cnt; //fill temp array except first position
tp++; //inc temp array position
cnt = 0; //reset counter
}
spos++; //inc main array position
ta[0]=tp; //how many sections
}
return ta;
}
}
}

