因为 currentTarget的类型是Object类型而 setChildIndex的参数要求是一个DisplayObject类型startDrag();也一样所以必须使用转换类型,才不会报错,至于为什么这个是一个Object类型,这是面向对象上的一些原因,你明白了后才会理解这个是为什么,这里就不详说了!!其实如果要置顶的话,可以直接这样写private function dragTile(e:MouseEvent):void { scene.addChild(e.currentTarget as Sprite);
(e.currentTarget as Sprite).startDrag(); ...