·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[AS3]TweenMax的围绕中心点旋转实例

时间:2015-11-19 13:48酷播
[AS3]TweenMax的围绕中心点旋转实例,新建一个sprite作为一个container,通过target.parent来替换target的位置和x,y

新建一个sprite作为一个container,通过target.parent来替换target的位置和x,y
然后target坐标归0,0
container.addChild(target);

两个tweenMax,一个旋转target,一个移动container

  1. override protected function doEffect():void{ 
  2.                         if(this.target.parent!=null){ 
  3.                                 container=new Sprite(); 
  4.                                 container.x=this.target.x; 
  5.                                 container.y=this.target.y; 
  6.                                  
  7.                                 this.target.parent.addChildAt(container,this.target.parent.getChildIndex(this.target)); 
  8.                                 container.addChild(this.target); 
  9.                                 this.target.x=0
  10.                                 this.target.y=0
  11.                                  
  12.                                 TweenMax.to(container,time-0.1,{x:x,y:y}); 
  13.                                  
  14.                                 TweenMax.to(target,time,{ease:Cubic.easeOut,transformAroundCenter:{ 
  15.                                         rotation:(round*360*direction) 
  16.                                 },onComplete:completeHandler}); 
  17.                                  
  18.                         }else{ 
  19.                                  
  20.                                 TweenMax.to(target,time,{ease:Cubic.easeOut,transformAroundCenter:{ 
  21.                                         rotation:(round*360*direction) 
  22.                                 },x:x,y:y,onComplete:completeHandler}); 
  23.                                  
  24.                         } 
  25.  
  26.                 } 
  27.                  
  28.                 private function completeHandler():void{ 
  29.                         if(container!=null){ 
  30.                                 container.parent.addChildAt(this.target,container.parent.getChildIndex(container)); 
  31.                                 this.target.x=container.x; 
  32.                                 this.target.y=container.y; 
  33.                         } 
  34.                         container=null
  35.                          
  36.                         effectComplete(); 
  37.                 } 

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器