Help with dynamically created MC!

Hi, I’m new here, and I’ve got a real problem.

I’m trying to create a sorting game, where the player has to choose the odd one out. I’ve loaded an XML that hold all my pictures for that level. What I’ve done is to put the XML into an array, then randomize the selection to two pictures by creating variables numA and numB, and putting them into another array.

Basically numA is the one that is correct, and whatever numB is the wrong, so i’ve loaded numA a number of times, according to what the user might input. I then randomized the array, to put them in random positions in the array. Then they’re loaded into a container_mc, that holds all the pictures.

Now, I have a catcher_mc that is supposed to be user controlled to choose which is the odd picture out. When the user clicks, it is supposed to drop down to the picture, and then drag the picture up. Or something like that.

I think I’ve just made it extremely complicated, and now I don’t know how to drag the picture that the catcher has landed on. The biggest problem for me now is how to identify which picture it has landed on.

Can anyone help? D:

(code might get lengthy. I’m pasting the whole thing here, if you want to see everything, in case I haven’t explained myself properly.)


/*
Flow of functions:

createContainer();
callXML();
loadXML();
chooseLevel(?,?);
getRandNums();
choosePic();
showPic();

*/

package {
    import flash.events.*;
    import flash.net.*;
    import flash.xml.*;
    import flash.display.*;

    public class sortMain extends MovieClip {
        var score:int=0;
        var numA:int;
        var numB:int;

        var totalImg:int;
        var level:int;// easy=1, normal=2, hard=3, expert=4
        var presentsXML:XML;
        var presArray:Array;//array of all presents of selected level
        var currPres:Array;//current array of presents
        var container_mc:MovieClip;
        var picWidth:Number=100;
        var options:int=5;//number of options


        var mouseXPos:int;
        var maxX:int=700;
        var minX:int=195;

        public function sortMain() {
            trace("Hello.");
            level=1;
            presArray = new Array();
            trace("Start array length = " + presArray.length);

            callXML();
            createContainer();

            stage.addEventListener(MouseEvent.MOUSE_MOVE, mousePos);
            stage.addEventListener(MouseEvent.CLICK, catcherDrop);
        }

        // start of functions for calling pictures //

        function callXML():void {
            var xmlLoader:URLLoader = new URLLoader();
            var xmlReq:URLRequest=new URLRequest("presents.xml");
            presentsXML = new XML();

            xmlLoader.addEventListener(Event.COMPLETE, loadXML);
            xmlLoader.load(xmlReq);
        }

        function createContainer():void {
            container_mc = new MovieClip();
            container_mc.x=155;
            container_mc.y=435;
            addChild(container_mc);

            container_mc.addEventListener(Event.ENTER_FRAME, hitTestPic);
        }

        function loadXML(e:Event):void {
            presentsXML=new XML(e.target.data);

            chooseLevel(presentsXML, level);

        }

        function getRandNums() {
            currPres = new Array();
            numA=Math.floor(Math.random()*presArray.length);
            numB=Math.floor(Math.random()*presArray.length);

            do {
                numB=Math.floor(Math.random()*presArray.length);
            } while (numB == numA);

            currPres.push(numA,numB);

            do {
                currPres.push(numA);
            } while (currPres.length < options);
            trace("current array of presents: " + currPres);

            currPres=randomizeArray(currPres);

            choosePic();
        }

        function randomizeArray(array:Array):Array {
            var newArray:Array = new Array();
            while (array.length > 0) {
                newArray.push(array.splice(Math.floor(Math.random()*array.length), 1));
            }
            return newArray;
        }

            for (var i:int=0; i<currPres.length; i++) {
                var loader:Loader = new Loader();
                var req:URLRequest=new URLRequest(presArray[currPres*]);
                loader.load(req);
                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showPic);

                loader.x = (picWidth + 15) * i;
            }

        }

        function showPic(e:Event):void {
            trace("picture shown");
            var pic:Loader=Loader(e.target.loader);
            container_mc.addChild(pic);
        }

        function chooseLevel(xml:XML, lvl:int) {
            var lvlList:XMLList = xml.images.(@level == lvl);

            for each (var image:XML in lvlList) {
                trace("image= "+image.img);
                presArray.push(image.img);
            }

            trace(presArray);
            trace("End array length = " + presArray.length);

            getRandNums();
        }

        // end functions for calling pictures //

        // start functions for catcher //

        function mousePos(e:MouseEvent):void {
            mouseXPos=mouseX;
            catcher_mc.x=mouseXPos;

            if (catcher_mc.x>=maxX) {
                catcher_mc.x=maxX;
            } else if (catcher_mc.x <= minX) {
                catcher_mc.x=minX;
            }
        }

        function catcherDrop(e:MouseEvent):void {
            var oriX:int=catcher_mc.x;

            trace("dropped");

            while (catcher_mc.y < 430) {
                catcher_mc.y+=0.5;
                catcher_mc.x=oriX;
            }

            stage.removeEventListener(MouseEvent.MOUSE_MOVE, mousePos);

        }

        function hitTestPic(e:Event):void {
            if (container_mc.hitTestObject(catcher_mc)) {
                trace("hit.");
            }

        }

        // end functions for catcher //