Sliding a mc addChild on MouseClick Event

Hi,

I’m having trouble to slide a mc that loads external image through a addChild function.

How do I change the code in order to slide the mc that contains the new mc addChild that the loader has created?

Heres my code, I have been trying to crack this for days and I couldn’t seem to solve it. Apologies if I don’t make sense, trying to convert myself from AS2 to AS3 :frowning:


var speed:Number=4;
var imageLoader:Loader;


//loading image via addChild function into mc

A_mc.addEventListener(Event.ENTER_FRAME, function(E:Event) {loadImage("images/img_gd_global_00.jpg");});
B_mc.addEventListener(Event.ENTER_FRAME, function(E:Event) {loadImage("images/img_gd_global_01.jpg");});


function loadImage(url:String):void {
    imageLoader = new Loader();
    imageLoader.load(new URLRequest(url));
    imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

}

function imageLoaded(E:Event):void {
    addChild(imageLoader);

}
function imageLoading(E:ProgressEvent):void {
}


// sliding the MC name
A_mc.dx=new Number();
B_mc.dx=new Number();

A_mc.addEventListener(Event.ENTER_FRAME,display_my_name_F);
B_mc.addEventListener(Event.ENTER_FRAME,display_my_name_F);

function display_my_name_F(E:Event):void {
    E.target.text=E.target.name;
    E.target.x+=(E.target.dx-E.target.x)/speed;
}

//click function on MC name
A_mc.addEventListener(MouseEvent.CLICK,hit_me_F);
B_mc.addEventListener(MouseEvent.CLICK,hit_me_F);


function hit_me_F(ME:MouseEvent):void {
    trace("total number of children in its parent:"+ME.target.parent.numChildren);
    ME.target.parent.setChildIndex(ME.target, ME.target.parent.numChildren-1);// place it at the top
    //ME.target.parent.setChildIndex(ME.target, 0);// place it at the bottom
    if (ME.target.dx==0) {
        ME.target.dx=-512;
    } else {
        ME.target.dx=0;
    }
}

Thanks in advance!