Parallax v0.1
© www.artcraft.cz
/**
* Copyright Good ( http://wonderfl.net/user/Good )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/rP1Q
*/
/**
* © 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(20);
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
}
);
}
}
}