简单跟随

记录一个效果:

 1 var total:int = 10;
 2 var mc:MovieClip;
 3 function init(total:int=10) {
 4     for (var i:int=0; i<total; i++) {
 5         var temp_mc:Hua=new Hua();
 6         addChild(temp_mc);
 7         temp_mc.x=stage.stageWidth/2;
 8         temp_mc.x=stage.stageHeight/2;
 9         temp_mc.scaleX = temp_mc.scaleY = 0.5 + (i +1)/ 20;
10         temp_mc.alpha = (((i +1)/ total)<0.3)?0.3:(i +1)/ total;
11         (i==total-1)?mc=MovieClip(temp_mc):0;
12     }
13 }
14 init();
15 addEventListener(Event.ENTER_FRAME,enter_Frame);
16 function enter_Frame(e:Event):void {
17     mc.x = mouseX;
18     mc.y = mouseY;
19     for (var i:int=total-1; i>0; i--) {
20         var mc_i = getChildAt(i);
21         var mc_i_1 = getChildAt(i - 1);
22         mc_i_1.x+=(mc_i.x-mc_i_1.x)/5;
23         mc_i_1.y+=(mc_i.y-mc_i_1.y)/5;
24     }
25 }
原文地址:https://www.cnblogs.com/ddw1997/p/1540687.html