/ Published in: ActionScript
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 // ************************************************** // // Author: ImHugo // URL: http://www.imhugo.com // ************************************************** // // Vars var arrayToRandom:Array = new Array(); var qRequired:Number = 5; // Inserts Numbers in Array for(var i:Number = 1; i<=qRequired; i++) { arrayToRandom.push( i ); } // Outputs numbers non-repeated for(var k:Number = 1; k<=qRequired; k++) { // Search for value inside the Array in a random position var randomPos:Number = Math.floor( Math.random() * arrayToRandom.length ); // Selects value and removes it from Array var valueFromArray = arrayToRandom.splice(randomPos, 1); // Converts value in number var numberRand = parseInt(valueFromArray); trace(numberRand); }
Comments
                    Subscribe to comments
                
                