import flash.events.MouseEvent; // 把服裝全部加上監聽滑鼠動作程式 for (var i=1; i<24; i++) { this["d"+i].addEventListener(MouseEvent.MOUSE_DOWN, doDrag); this["d"+i].addEventListener(MouseEvent.MOUSE_UP, doDrop); } // 加入拖曳服裝函數 function doDrag(event:MouseEvent):void { var dress = event.target; dress.startDrag(); // 把被拖曳的衣服放在最上層 setChildIndex(dress, numChildren -1); } // 加入放開拖曳服裝函數 function doDrop(event:MouseEvent):void { var dress = event.target; dress.stopDrag(); }