• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

AS3实现的3D相册效果代码

OC/C/C++ 水墨上仙 2921次浏览

AS3实现的3D相册效果代码
来源:http://www.adamcoulombe.info/lab/as3/screen-to-screen.html

import com.greensock.*;
import com.greensock.easing.*;
var lastRotX = 0;
var lastRotY = 0;
 
for(var i=0; i<gal.numChildren; i++){
	var self = gal.getChildAt(i);
	self.addEventListener(MouseEvent.CLICK,windowClicked);
}
 
addEventListener(Event.ENTER_FRAME,loop);
function windowClicked(e){
	var self = e.currentTarget;
	removeEventListener(Event.ENTER_FRAME,loop);
	var timeline = new TimelineLite();
	var transition = new TimelineLite();
	timeline.insert(TweenLite.to(gal,1,{x:(self.x)*-1,y:(self.y)*-1, z:-1210, ease: Sine.easeInOut}));
	timeline.insert(transition);
	lastRotX = gal.rotationX;
	lastRotY = gal.rotationY;
	var oppRotX = gal.rotationX*-1;
	var oppRotY = gal.rotationY*-1;
	transition.append(TweenLite.to(gal,0.5,{rotationX:oppRotX*7,rotationY:oppRotY*7, ease: Sine.easeOut})); 
	transition.append(TweenLite.to(gal,0.5,{rotationX:0,rotationY:0, ease: Sine.easeIn})); 	
	self.removeEventListener(MouseEvent.CLICK,windowClicked);
	self.addEventListener(MouseEvent.CLICK,zoomOut);
}
function zoomOut(e){
	var self = e.currentTarget;
 
	self.addEventListener(MouseEvent.CLICK,windowClicked);
	var timeline = new TimelineLite();
	var transition = new TimelineLite({onComplete:function(){	addEventListener(Event.ENTER_FRAME,loop) }});
	timeline.insert(TweenLite.to(gal,1,{x:573,y:422, z:0, ease: Sine.easeOut}));
	timeline.insert(transition);
	transition.append(TweenLite.to(gal,0.5,{rotationX:lastRotX*7,rotationY:lastRotY*7, ease: Sine.easeOut})); 
	transition.append(TweenLite.to(gal,0.5,{rotationX:0,rotationY:0, ease:Sine.easeInOut})); 
 
}
function loop(e){
	var distx:Number = mouseX / 650;
	var disty:Number = mouseY / 450;
	TweenLite.to(gal, 2, {
						rotationY:(-70 + (140*distx))*0.06,
						rotationX:(70 - (140*disty))*0.06,
						ease:Expo.easeOut
				 });
}


喜欢 (0)
加载中……