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

SeaofSphere

...
@author Nobuhiro Takahashi
// write as3 code here..
package 
{
    import flash.display.BlendMode;
    import flash.display.MovieClip;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.BlurFilter;
    
    /**
     * ...
     * @author Nobuhiro Takahashi
     */
    [SWF(width="465", height="465", backgroundColor=0x000000, frameRate=30)]
    public class SeaOfSphere extends Sprite
    {
        private var fl:Number = 300;
        private var vpX:Number;
        private var vpY:Number;
        
        private var world:Sprite = new Sprite();
        private var spheres:Array = new Array();
        
        public function SeaOfSphere()
        {
            vpX = this.stage.stageWidth / 2;
            vpY = this.stage.stageHeight / 2;
            
            addChild(world);
            
            var blend:Array = [];
            blend = [
                BlendMode.NORMAL,
                BlendMode.HARDLIGHT,
                BlendMode.DARKEN,
                BlendMode.MULTIPLY,
                BlendMode.ADD,
                BlendMode.DIFFERENCE,
                BlendMode.ERASE,
                BlendMode.INVERT,
                BlendMode.OVERLAY,
                BlendMode.SUBTRACT
            ];
            
            var blur:BlurFilter = new BlurFilter(32, 32, 1);
            for (var i:int = 0; i < 30; i++)
            {
                var sphere:MovieClip = new MovieClip();
                
                sphere.xpos = Math.random() * 200 - 100;
                sphere.ypos = Math.random() * -200;
                sphere.zpos = Math.random() * 100 - 50;
                sphere.startX = sphere.xpos;
                sphere.startY = sphere.ypos;
                sphere.startZ = sphere.zpos;
                sphere.r = Math.random() * 360 - 180;
                sphere.v = Math.random() * 1 - .5;
                
                var s:Shape = new Shape();
                s.graphics.beginFill(Math.random() * 0x9fffff, 1);
                s.graphics.drawCircle(0, 0, Math.random() * 30 + 30);
                s.graphics.endFill();
                s.filters = [blur];
                //sphere.blendMode = blend[Math.floor(Math.random() * blend.length)];
                sphere.blendMode = BlendMode.ADD;
                
                sphere.addChild(s);
                world.addChild(sphere);
                
                
                spheres.push(sphere);
            }
            
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
        }
        private function enterFrameHandler(e:Event):void
        {
            for (var i:int = 0; i < spheres.length; i++)
            {
                spheres[i].r += spheres[i].v;
                spheres[i].xpos = Math.cos(spheres[i].r / 180 * Math.PI) * 120 + spheres[i].startX;
                spheres[i].ypos = Math.sin(spheres[i].r / 180 * Math.PI) * -120 + spheres[i].startY;
                spheres[i].zpos = Math.sin(spheres[i].r / 180 * Math.PI) * 200 + spheres[i].startZ;
            }
            
            for (i = 0; i < spheres.length; i++)
            {
                var scale:Number = fl / (fl + spheres[i].zpos);
                spheres[i].scaleX = spheres[i].scaleY = scale;
                spheres[i].x = vpX + spheres[i].xpos * scale;
                spheres[i].y = vpY + spheres[i].ypos * scale;
            }
            
            spheres.sortOn("zpos", Array.DESCENDING);
            for (i = 0; i < spheres.length; i++)
            {
                world.setChildIndex(spheres[i], world.numChildren - 1);
            }
        }
    }
    
}