宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

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

2016-10-13 00:16:48 点击量:34 标签: 收藏本文

新建一个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.                 } 

 

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室