Hey Ilyas, Sen, Eyez, and all the other super master coders here, I need a little help on something.
Last night I got working on a way to randomize the contents of an array. Well what I need help with is… I was wondering if my method is in-effecient, and if so, how do I make it efficient?
I am not really using it for anything, I just wanted to see if I could find a way to do it because I don’t think there are any AS commands that allow you to do it.
I just checked http://www.layer51.com/proto/ to see if anyone did anything similar for randomizing arrays… AND GUESS WHAT!!!
Thats right, Robert Penner already did one, but oddly enough, it looks EXACTLY like what I did!!!
WTF!?!?! I spent like an hour writing this thing.
[AS]Array.prototype.shuffle = function() {
var len = this.length;
for (var i=0; i < len; i++) {
var rand = Math.floor(Math.random()len);
//swap current index with a random one
var temp = this;
this* = this[rand];
this[rand] = temp;
}
}[/AS]
LOL, never thought about it that way Thor. Hmmm… I may think like them, just at a MUCH MUCH MUCH slower pace
Nah, I am over it now, just kinda got fumed to see that what I did already existed anyway and I coulda saved myself time just by looking first. But you know what, I DID learn something, and I DID accomplish a task I wanted to accomplish on my own, so I don’t have anything to complain about, now I am just hungry.
hey i have an idea! let’s make a site! dan’s dad [size=1]who doesn’t have a member (you know what i’m talking about)[/size] can host us, edwin can draw and design the site, and i can sit back and put my name all over it…oh yeah, and code!!!