Skip to content

Instantly share code, notes, and snippets.

@holmeszyx
Last active December 26, 2015 09:59
Show Gist options
  • Select an option

  • Save holmeszyx/7133182 to your computer and use it in GitHub Desktop.

Select an option

Save holmeszyx/7133182 to your computer and use it in GitHub Desktop.
改了下名,好看一点点
public function getLocation(_arg1:String):String{
var startvar:*;
var blockCont:* = Number(_arg1.charAt(0));
var realString:* = _arg1.substring(1);
var blockLength:* = Math.floor((realString.length / blockCont));
var remainLength:* = (realString.length % blockCont);
var pool:* = new Array();
var currentIndex:* = 0;
while (currentIndex < remainLength) {
if (pool[currentIndex] == undefined){
pool[currentIndex] = "";
};
pool[currentIndex] = realString.substr(((blockLength + 1) * currentIndex), (blockLength + 1));
currentIndex++;
};
currentIndex = remainLength;
while (currentIndex < blockCont) {
pool[currentIndex] = realString.substr(((blockLength * (currentIndex - remainLength)) + ((blockLength + 1) * remainLength)), blockLength);
currentIndex++;
};
var perString:* = "";
currentIndex = 0;
while (currentIndex < pool[0].length) {
startvar = 0;
while (startvar < pool.length) {
perString = (perString + pool[startvar].charAt(currentIndex));
startvar++;
};
currentIndex++;
};
perString = unescape(perString);
var locationString:* = "";
currentIndex = 0;
while (currentIndex < perString.length) {
if (perString.charAt(currentIndex) == "^"){
locationString = (locationString + "0");
} else {
locationString = (locationString + perString.charAt(currentIndex));
};
currentIndex++;
};
locationString = locationString.replace("+", " ");
return (locationString);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment