import flash.events.MouseEvent;
orgText.text = "9,1,1,0,0,2],[93,,,,,1,,]],[23,[0,,,,,0,],[24,,,,,0,],[79,53,180,1,1,0,0,2],[93,,,,,1,,]],[18,[0,,,,,0,],[24,,,,,0,],[72,433,39,1,1,1,0,]],[17,[0,,,,,0,],[24,-591,17,1,1,1,0,3],[47,32,,,,,,],[72,,,,,,,2],[79,-63,,,,,,1],[90,-591,,,,,,],[91,,,,,0,]],[16,[0,49,35,1,1,1,0,]],[15,[0,,,,,0,],[24,-592,16,1,1,1,0,3],[47,31,,,,,,],[72,,,,,,,2],[79,-64,,,,,,1],[90,-592,,,,,,],[91,,,,,0,]],[14,[0,,,,,0,],[24,1252,19,1,1,1,0,3],[47,592,,,,,,],[72,,,,,,,2],[90,1252,,,,,,],[91,,,,,0,]],[13,[0,28,15,0.999,1,1,0,]],[12,[0,23,17,1,1,1,0,]],[11,[0,,,,,0,],[24,,,,,0,],[79,407,188,1,1,0,0,2],[93,,,,,1,,]],[10,[0,,,,,0,],[24,,,,,0,],[79,403,459,0.994,1,0,0,2],[93,408,456,,,1,,]],[9,[0,,,,,0,],[24,,,,,0,],[79,405,185,1,1,0,0,2],[93,,,,,1,,]],[8,[0,,,,,0,],[24,,,,,0,],[79,896,185,1,1.016,0,0,2],[93,,,,1,1,,]],[7,[0,,,,,0,],[24,,,,,0,],[79,404,185,1,1.011,0,0,2],[93,,186,,1,1,,]],[6,[0,,,,,0,],[24,,,,,0,],[79,920,57,1,1,0,0,2],[93,,,,,1,,]],[5,[0,27,481,0.997,1,1,0,]],[4,[0,1245,18,1,1,1,0,]],[3,[0,,,,,0,],[24,,,,,0,],[79,1205,443,1,1,0,0,2],[93,,,,,1,,]],[2,[0,,,,,0,],[24,,,,,0,],[79,1161,445,1,1,0,0,2],[93,,,,,1,,]]],[1212,[27,[0,,,,,0,],[24,,,,,0,],[79,140,396,1,1,0,0,2],[93,,,,,1,,]],[26,[0,,,,,0,],[24,,,,,0,],[79,37,468,1,1,0,0,2],[93,,,,,1,,]],[25,[0,,,,,0,],[24,,,,,0,],[79,369,469,1,1,0,0,2],[93,,,,,1,,]],[23,[0,,,,,0,],[24,,,,,0,],[79,38,180,1,1,0,0,2],[93,,,,,1,,]],[18,[0,,,,,0,],[24,,,,,0,],[72,389,39,1,1,1,0,]],[17,[0,,,,,0,],[24,-635,17,1,1,1,0,3],[47,-12,,,,,,],[72,,,,,,,2],[79,-107,,,,,,1],[90,-635,,,,,,],[91,,,,,0,]],[16,[0,49,35,1,1,1,0,]],[15,[0,,,,,0,],[24,-635,16,1,1,1,0,3],[47,-12,,,,,,],[72,,,,,,,2],[79,-107,,,,,,1],[90,-635,,,,,,],[91,,,,,0,]],[14,[0,,,,,0,],[24,1209,19,1,1,1,0,3],[47,549,,,,,,],[72,,,,,,,2],[90,1209,,,,,,],[91,,,,,0,]],[13,[0,27,15,0.945,1,1,0,]],[12,[0,23,1"
var str:String = orgText.text;
var len = str.length;
var childC:Array = [];
function findSame(index,result)
{
if(index < len)
{
if(index+1 < len)
{
var cChar = str.charAt(index);
var nextChar = str.charAt(index+1);
if(cChar == nextChar)
{
result += nextChar;
findSame(index+1,result);
}
else
{
childC.push(result);
findSame(index+1,nextChar);
}
}
else
childC.push(result);
}
}
searchBtn.addEventListener(MouseEvent.CLICK,onSearch)
function onSearch(e:MouseEvent)
{
str = orgText.text;
len = str.length;
childC = [];
findSame(0,str.charAt(0));
var cloneArr:Array = childC.concat();
var checkIndex = 0;
var info = {};
while(checkIndex < cloneArr.length)
{
var child = childC[checkIndex];
var idx;
while( (idx = cloneArr.indexOf(child)) != -1)
{
cloneArr.splice(idx,1);
info[child] = (info[child] == undefined ? 1 : info[child]+1);
}
checkIndex++;
}
var infoStr = "";
for(var obj in info)
{
//trace(count +"_____________" + "'"+obj+"'" + " 出现次数 " + info[obj]);
infoStr += ("字符:" + "'"+obj+"'" + " 出现次数 " + info[obj] + "\n");
}
infoText.text = infoStr;
replaceBtn.addEventListener(MouseEvent.CLICK,onReplace);
}
function onReplace(e:MouseEvent)
{
var org = orgIndex.text;
trace("开始替换 " +org + "to" +replaceChar.text);
while(str.indexOf(org) != -1)
str = str.replace(org,replaceChar.text);
resultText.text = str;
}