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

forked from: forked from: forked from: forked from: massmedian challenge

Get Adobe Flash player
by Aksor.Al 07 Jan 2011
    Embed
/**
 * Copyright Aksor.Al ( http://wonderfl.net/user/Aksor.Al )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rXxZ
 */

// forked from jacknero's forked from: forked from: forked from: massmedian challenge
// forked from hacker_osfam7x6's forked from: forked from: massmedian challenge
// forked from Murai's forked from: massmedian challenge
// forked from checkmate's massmedian challenge
package {
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.net.*;
    import flash.system.LoaderContext;
    import flash.media.*;
    import flash.utils.*;
    import flash.system.*
    import flash.text.*
    
    [SWF(width="565",height="465",frameRate="60")];
    public class Begineer extends Sprite{
                
                
        //-------------------------------//
        // Use properties as follows.
        //-------------------------------//
        private var _sliceList:Array;
        private var sound:Sound;
        private var channel:SoundChannel;
        private var bA:ByteArray;
        private var txt:TextField;
        
        
        //-------------------------------//
        // Change functions as follows.
        //-------------------------------//

        public function updateEnterFrame( e:Event ):void{
            if(!sound){
                                stage.quality = "autolow";
                //Security.loadPolicyFile("http://level0.kayac.com/crossdomain.xml");
                bA=new ByteArray();
                sound=new Sound();
                sound.load(new URLRequest(""));
                sound.addEventListener(Event.COMPLETE,function(e:Event):void{
                   channel=sound.play(0,9999);
                });    
            }
            
            var len:uint=_sliceList.length;
            var tN:Number=0;
            var h:Number=0;
            var nH:Number=0;
            var sH:Number=stage.stageHeight;
                        var sW:Number=stage.stageWidth;
            var cY:uint=233;
            
            SoundMixer.computeSpectrum(bA,false,0);                     

            for(var i:uint=0;i<len;i++){
                h=_sliceList[i].height;
                if((bA.position/bA.length-1))nH=bA.readFloat()*sH;
                
                _sliceList[i].y=Math.random()*50-25;
                tN=(h>460)?0:(0<h)?sH:0;
                
                _sliceList[i].height=nH;
                _sliceList[i].height+=(tN-_sliceList[i].height)/5;
                                _sliceList[i].y+=(tN-_sliceList[i].height)/3;
                                _sliceList[i].x=Math.floor(i/len*sW);
            }
        } 


        
        //-------------------------------//
        // Do not change following codes.
        //-------------------------------//
        public function Begineer(){
            var ctxt  :LoaderContext = new LoaderContext(true);
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
            loader.load( new URLRequest("http://swf.wonderfl.net/static/assets/massmedian.png"), ctxt );
        }
        
        public function onLoadComplete(e:Event):void {
            var loader:Loader = LoaderInfo( e.target ).loader;
            loader.contentLoaderInfo.removeEventListener( Event.COMPLETE, onLoadComplete );
            
            var bitmapdata:BitmapData = new BitmapData( loader.width, loader.height, true, 0xFF0000 );
            bitmapdata.draw( loader );
            
            _sliceList = sliceBanner( bitmapdata, bitmapdata.width );
            
            addEventListener( Event.ENTER_FRAME, updateEnterFrame );
        }
        
        
        private function sliceBanner( banner:BitmapData, length:int = 100 ):Array{
            var sliceList:Array = [];
            var w:int = Math.floor( banner.width/length );
            var h:int = Math.floor( banner.height );
            
            var t:int = Math.ceil( banner.width - w*length );
            var mat:Matrix = new Matrix();
                
            for( var i:int = 0; i<length; i++ ) {
                var bmpd :BitmapData = new BitmapData( w, h, true, 0xFFFF00 );
                mat.tx = -w*i;
                bmpd.draw( banner, mat );
                var part:DisplayObject = addChild( new Bitmap( bmpd ) );
                part.x = w*i;
                sliceList.push( part );
            }
            return sliceList;
        }
        
    }
}