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: Parallax v0.1

© www.artcraft.cz
Get Adobe Flash player
by my_design09 10 Dec 2011
/**
 * Copyright my_design09 ( http://wonderfl.net/user/my_design09 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/d8x9
 */

// forked from Good's Parallax v0.1
/**
*  © www.artcraft.cz
**/


package {
    import flash.system.LoaderContext;
    import gs.TweenLite;
    
    import flash.geom.PerspectiveProjection;
    
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    
    public class Parallax extends Sprite {
        Wonderfl.capture_delay(5);       
       
        private const MATERIAL_URL:String = 
        "http://assets.wonderfl.net/images/related_images/b/be/be55/be55c4c0b4b2ba27dae1e72429a1141dcca4e7c3";    
        
        private var _s:Sprite;
        private var _pp:PerspectiveProjection;
                
        public function Parallax() {
            _s = new Sprite();
            addChild(_s) ;
            _s.x = stage.stageWidth / 2;
            _s.y = stage.stageHeight / 2;
            
            var lc:LoaderContext = new LoaderContext(true);
            
            var loader:Loader = new Loader();
            loader.load( new URLRequest( MATERIAL_URL), lc);
            _s.addChild(loader);
            loader.x = loader.y = -250;
            
            var loader2:Loader = new Loader();
            loader2.load( new URLRequest( MATERIAL_URL), lc);
            _s.addChild(loader2);
            loader2.x = loader2.y = -250;
            loader2.z = 100;
            
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
        }
        
        private function onMouseMove(e:MouseEvent):void{
            TweenLite.to(_s, 1, 
                {
                    rotationY:(stage.mouseX/stage.stageWidth - .5) * 30 , 
                    rotationX:(stage.mouseY/stage.stageHeight - .5) * -20 
                }
            );
        }
    }
}