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: flash on 2009-11-18

Get Adobe Flash player
by ish_xxxx 06 Jul 2012
/**
 * Copyright ish_xxxx ( http://wonderfl.net/user/ish_xxxx )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/f9so
 */

package {
    import flash.utils.ByteArray;
    import org.libspark.thread.EnterFrameThreadExecutor;
    import org.papervision3d.materials.MovieMaterial;
    import org.papervision3d.objects.primitives.Cylinder;
    import org.papervision3d.view.BasicView;
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import org.libspark.thread.Thread;
    import jp.progression.commands.*;
    import jp.progression.commands.display.*;
    import jp.progression.commands.net.*;
    import jp.progression.commands.lists.*;
    public class FlashTest extends BasicView {
        public var taiga:Sprite, ball:Cylinder, m:MovieMaterial, a:Array=[], loader:Loader = new Loader, data:ByteArray;
        public function FlashTest() {
            super( 0, 0, true, true );
            taiga = new Sprite();
            setup();
        }
        public function setup(): void {
            var imgUrl:String = "http://assets.wonderfl.net/images/related_images/e/e9/e9b6/e9b64ead20dd3d674e79ea186b29f974341b480f";
            Thread.initialize( new EnterFrameThreadExecutor );
            camera.ortho = false;
            new DataLoadThread( dataLoaded, imgUrl ).start();
        }
        protected function dataLoaded( __data:ByteArray ): void{
            loader.contentLoaderInfo.addEventListener( Event.COMPLETE, loaded );
            loader.loadBytes( __data );
        }
        protected function loaded( ev:Event ): void {
            taiga.addChild( Loader( LoaderInfo( ev.currentTarget ).loader ) );
            var l:uint = 25;
            while( l-- ) {
                m = new MovieMaterial( taiga );
                ball = new Cylinder( m, Math.max( 40, Math.random() * 80 ), Math.max( 300, Math.random() * 500 ) );
                ball.autoCalcScreenCoords = true;
                ball.x = Math.random() * 1000 - Math.random() * 1000;
                ball.z = Math.random() * 1000 - Math.random() * 1000;
                a.push( { ball: ball, offset: Math.random()*20 -Math.random()*20 } );
                scene.addChild( ball );
            }
            startRendering();
        }
        override protected function onRenderTick( ev:Event = null ) :void
        {
            var l:uint = a.length;
            while ( l-- ) {
                a[l].ball.rotationY += a[l].offset;
                a[l].ball.y += a[l].offset;
                if ( a[l].ball.y > 1000 ) {    a[l].ball.y = -1000;    }
                if ( a[l].ball.y < -1000 ) {    a[l].ball.y = 1000;    }
            }
            renderer.renderScene( scene, camera, viewport );
        }
    }
}
import org.libspark.thread.Thread;
import org.libspark.thread.threads.net.URLLoaderThread;
import org.libspark.thread.utils.SerialExecutor;
import flash.net.*;
internal class DataLoadThread extends Thread
{
    public var callback:Function, url:String, s:SerialExecutor;
    public function DataLoadThread( __callback:Function, __url:String )
    {
        super();
        callback = __callback || trace; 
        url = __url;
    }
    protected override function run():void{
        s = new SerialExecutor;
        var ul:URLLoader = new URLLoader; ul.dataFormat = URLLoaderDataFormat.BINARY;
        s.addThread( new URLLoaderThread( new URLRequest( url ), ul ) );
        s.start(); s.join(); next( end );
    }
    protected function end(): void{
        callback( URLLoaderThread( s.getThreadAt(0) ).loader.data );
    }
}