i know it isnt much, but i wanted to try my hand at an FOSS, so check it out.
this is to create a word scramble, such as you would find in a puzzle game...
http://media.putfile../wordscrambleV11/640
-=- RAW CODE -=-
var correct:String = "This String Will Be Scrambled"
var broken:Array = new Array();
broken = correct.split(" ")
for (i=0; i<broken.length; i++){
broken[i] = broken[i].split("");
var scram:Array = [];
for (j=broken[i].length; j>0; j--){
var where:Number = int(Math.random()*broken[i].length);
scram.push(broken[i][where]);
broken[i].splice(where, 1);
}
broken[i] = scram
broken[i] = broken[i].join("");
}
var scramver:String = broken.join(" ");
trace(scramver);
-=- EXPLAINATION -=-
var correct:String = "This String Will Be Scrambled"
here is the string that we will start with
var broken:Array = new Array();
broken = correct.split(" ")
this is where the string is broken into seperate words
for (i=0; i<broken.length; i++){
this will run the following code seperately for each word
broken[i] = broken[i].split("");
this will be the array broken into a nested array of the letters, seperately
var scram:Array = [];
here is where we will put the scrambled version of each word
for (j=broken[i].length; j>0; j--){
var where:Number = int(Math.random()*broken[i].length);
selects a random letter out of the word
scram.push(broken[i][where]);
adds the letter to the "scrambled" array
broken[i].splice(where, 1);
remove the letter from the original word
}
broken[i] = scram
broken[i] = broken[i].join("");
replaces the word with the scrambled word, and then puts it back together.
}
var scramver:String = broken.join(" ");
puts all of the words back together into one massive string
trace(scramver);
thats the final product
umm, enjoy. i hope you like the open source, and id like to see if anyone can make this something new. im sure you could combine this with an array stored with where each letters original location was in order to make passwords or some sort of rudimentary encryption. i would imagine that this could have more usage than just a simple word scramble, but that was the original intention of the code.
heres the final product again:
http://media.putfile../wordscrambleV11/640
