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

--

Get Adobe Flash player
by hemingway 01 May 2015
    Embed
/**
 * Copyright hemingway ( http://wonderfl.net/user/hemingway )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rg0p
 */

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.ui.*;
    import com.risonhuang.pixas.math.Coord3D;
    import com.risonhuang.pixas.math.ColorPattern;
    import com.risonhuang.pixas.colors.CubeColor;
    import com.risonhuang.pixas.dimensions.CubeDms;
    import com.risonhuang.pixas.objects.primitives.Cube;
    import com.risonhuang.pixas.objects.PixelObject;
    
    [SWF(frameRate=60, width=465, height=465)]
    public class PixasTest3D extends Sprite
    {
        private var pixelCanvas:PixelObject = new PixelObject();
        private var pixels:Vector.<Pixel>;
        
        public function PixasTest3D()
        {
            this.initializePixels(new <int>[this.stage.stageWidth/2, this.stage.stageHeight/2], 8);
            this.addEventListener(Event.ENTER_FRAME, this.updatePixels);
            this.stage.addEventListener(MouseEvent.MOUSE_DOWN, this.mouseDownHandler);
        }
        
        private function initializePixels($pos:Vector.<int>, $size:int):void {
            this.pixels = new Vector.<Pixel>;
            
            this.addChild(this.pixelCanvas);
            this.pixelCanvas.x = $pos[0];
            this.pixelCanvas.y = $pos[1];

            
            var $pixelCoordinates:Coord3D = new Coord3D(0, 0, 0);
            var $pixelDimensions:CubeDms = new CubeDms($size, $size, $size);
            var $pixelColor:CubeColor = CubeColor.getByHorizontalColor(0x565656);
            var $pixelShape:Cube = new Cube($pixelDimensions, $pixelColor, false);
            
            for (var $:int = 0; $<4; $++) {
                for (var $$:int = 0; $$<4; $$++) {
                    for (var $$$:int = 0; $$$<4; $$$++) {
                        this.pixels.push(new Pixel($pixelShape, $pixelCoordinates));
                        this.pixels[$].positionZ = 200 + (8*$);
                        this.pixels[$].positionX = (8*$);
                        this.pixels[$].positionY = (8*$);
                        this.pixelCanvas.addChild(this.pixels[$]);    
                    }

                }

                //this.pixels.push(new Pixel($pixelShape, $pixelCoordinates));
                //this.pixels[$].positionZ = (200);
                //this.pixels[$].positionX = (8 * $);
                //this.pixelCanvas.addChild(this.pixels[$]);
            }
        }
        
        private function mouseDownHandler($event:Event):void {
            for (var $:int = 0; $<this.pixels.length; $++) {
                this.pixels[$].positionZ = (200);
            }
        }

        public function updatePixels($event:Event):void {
            
            for (var $:int = 0; $<this.pixels.length; $++) {
                var $calcVelocityZ:int = 0;
                var $calcInverseVelocityZ:int = 1;
                
                if (this.pixels[$].positionZ > 0) {
                    if (this.pixels[$].velocityZ < 20) {
                        this.pixels[$].velocityZ++;
                    }else{
                        this.pixels[$].velocityZ = 20;
                    }          
                    
                    if ((this.pixels[$].positionZ - this.pixels[$].velocityZ) <= 0) {
                        $calcVelocityZ = (this.pixels[$].velocityZ - this.pixels[$].positionZ);
                        $calcInverseVelocityZ = (this.pixels[$].velocityZ * 0.55);
                    }
                }
                
                if ($calcVelocityZ) {
                    this.pixels[$].positionZ -= (this.pixels[$].velocityZ - $calcVelocityZ);
                    this.pixels[$].velocityZ =~ ($calcInverseVelocityZ-1);
                }else{
                    if ((this.pixels[$].positionZ - this.pixels[$].velocityZ) == 0) {
                        this.pixels[$].velocityZ =~ (this.pixels[$].velocityZ-1)*0.55;
                    }

                    this.pixels[$].positionZ -= this.pixels[$].velocityZ;
                }
            }
        }
    }
}

import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.ui.*;
import com.risonhuang.pixas.math.Coord3D;
import com.risonhuang.pixas.math.ColorPattern;
import com.risonhuang.pixas.colors.CubeColor;
import com.risonhuang.pixas.dimensions.CubeDms;
import com.risonhuang.pixas.objects.primitives.Cube;
import com.risonhuang.pixas.objects.PixelObject;

internal class Pixel extends PixelObject {
    public var velocityX:int;
    public var velocityY:int;
    public var velocityZ:int;    
    
    public function Pixel($pixelShape:*, $pixelCoordinates:Coord3D):void {
        super($pixelShape, $pixelCoordinates);
        
        this.velocityX = 0;
        this.velocityY = 0;
        this.velocityZ = 0;
    }


}