/ Published in: ActionScript 3
                    
                                        This is very simple script, you can add ass meny items and arrays as you want. You can change the separator and/or enging of the sentance. It can be very easily modified to work with external XML files
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 var sentance:Array = [ ["Name 1", "Name 2", "Name 3", "Name 4", "Name 5"], ["and", "without", "and somehow", "and his twin sister"], ["Girl name 1", "Girl name 2", "Girl name 3", "Girl name 4"], ["went ot school", "passed the exams", "went on vacation", "voted for Obama"] ] var finalString:String = ""; var separator:String = " "; var end:String = "."; for(var i:Number = 0; i< sentance.length; i++){ finalString += String(sentance[i][Number( Math.ceil( Math.random()*sentance[i].length-1 ))] + separator); } finalString = finalString.slice(0, finalString.lastIndexOf(separator)) + end; trace(finalString); //output: Name 2 and somehow Girl name 4 voted for Obama. //or output: Name 3 and his twin sister Girl name 1 passed the exams.
Comments
                    Subscribe to comments
                
                