package
{
import flash.display.Sprite;
import flash.events.*;
public class Main extends Sprite
{
public function Main()
{
var aSpr:Sprite = new Sprite();
var bSpr:Sprite = new Sprite();
var cSpr:Sprite = new Sprite();
var dSpr:Sprite = new Sprite();
aSpr.addEventListener(MouseEvent.MOUSE_DOWN, swapSprites);
bSpr.addEventListener(MouseEvent.MOUSE_DOWN, swapSprites);
cSpr.addEventListener(MouseEvent.MOUSE_DOWN, swapSprites);
dSpr.addEventListener(MouseEvent.MOUSE_DOWN, swapSprites);
addChild(aSpr);
addChild(bSpr);
addChild(cSpr);
addChild(dSpr);
}
private function swapSprites(evt:Event):void
{
swapChildren((evt.target as Sprite), getChildAt(numChildren - 1));
}
}
}