In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Age-of-Empires-Like Random Charts? (just reload :D)

«Random Charts created with an XML object»
was playing and learning XML a then just imagine this LOL, but I want to make every   graph random... yea it requires just a bit of time.
Get Adobe Flash player
by faunus 04 Jan 2012
/**
 * Copyright faunus ( http://wonderfl.net/user/faunus )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/m82N
 */

package {
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.display.Graphics;
 
    public class FlashTest extends Sprite {
        
        public var chart        :XML;
        public var X            :Number = 44;
        public var Y            :Number = 88;
        public var u            :Number = 22;//unity
        public var graphs       :Number = 6; 
        public var ranColor     :Number;
        public var ranColor0x   :String;
        public var large        :Number = 22; //data per chart
        public var alt          :Number = 88; //height
        
        public function FlashTest() {
            // write as3 code here..
          
            chart    =    <perfil var1 = " 1111" var2 = "2222 " var3 = " 3333 " var4 = " 44 44 ">
                                <jamon id="0"> 45 </jamon>
                                <seso id="0"> 70</seso>
                                   <destreza id="0">32     </destreza>
                                <leche>12</leche>
                            </perfil>;
            
            while( chart.jamon.length() < large )
            {
                var jamon:XML = <jamon> {trueRandom( 2,88 )} </jamon>
                  jamon.@id = chart.jamon.length().toString();
                   chart.appendChild(jamon);
            }
            
            while( chart.seso.length() < large )
            {
                var seso:XML = <seso> {trueRandom( 2 , 88 )} </seso>
                  seso.@id = chart.seso.length().toString();
                   chart.appendChild(seso);
            }
            
            while( chart.leche.length() < large )
            {
                var leche:XML = <leche> {trueRandom( 2 , 88 )} </leche>
                  leche.@id = chart.leche.length().toString();
                   chart.appendChild(leche);
            }
            
            var fila  :Number;
            var i     :Number;
            for ( fila = 1; fila <= graphs; fila++ )
            {
                ranColor = trueRandom(0,999999);
                ranColor0x = "0x"+ranColor.toString();
                graphics.lineStyle( 2,  Number(ranColor0x) );
                
                ranColor = trueRandom(0,999999);
                ranColor0x = "0x"+ranColor.toString();
                graphics.beginFill( Number(ranColor0x) );
                
                graphics.moveTo(X,Y*fila+alt);//0
            
                for ( i=0; i < chart.jamon.length(); i++ )
                {
                    
                    graphics.lineTo( X+i*u,(Y*fila)-Number(chart.jamon[i]) );
                }
                graphics.lineTo( X+(i-1)*u,Y*fila+alt);//end
                
            }
        }
        
        public function trueRandom(minNum:Number, maxNum:Number):Number  
        {  
            return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);  
        } 
        
    }//class
}//pkg