createEmptyMovieClip and onRollOver

I’ve seen some posts from people with similar problems but I cannot seem to get this to work so I decided to post my own thread.

I’m dynamically creating movieclips and using loadMovie to load jpg images from an xml file. But I cannot get the onRollOver, or any other event handler to work. Here is my code:


var images:XML = new XML();

images.ignoreWhite = true;

images.onLoad = function(success:Boolean):Void {
    if(success) {
        var xmlDoc = this.firstChild;
        var total:Number = xmlDoc.childNodes.length - 1;
        img = [];
        for(var i=1; i<=total; i++) {
            img* = xmlDoc.childNodes*.firstChild.nodeValue;
            _root.createEmptyMovieClip("home"+i, i);
            var home_mc:MovieClip = _root["home"+i];
            home_mc.loadMovie(img*, i);
            home_mc._x = Math.random()*200;
            home_mc._rotation = Math.random()*30;
            home_mc.onRollOver = function() {
                trace("im hit");
            }
        }
    }
}

images.load("images.xml");

I used the home_mc._x and home_mc._rotation to let me see all the photos and try the onRollOvers and test to see if they all got loaded, which they did just fine.

Any ideas? I’m thinking this is something simple and stupid but I guess I’ve been staring at it too long to realize the problem.