# createEmptyMovieClip and onRollOver

**URL:** <https://forum.kirupa.com/t/createemptymovieclip-and-onrollover/227717>\
**Category:** flash\
**Created:** [June 1, 2007, 2:13pm UTC](https://forum.kirupa.com/t/createemptymovieclip-and-onrollover/227717 "2007-06-01T14:13:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamiller](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jamiller/32/3433_2.png) [@jamiller](https://forum.kirupa.com/u/jamiller)\
**Post date:** [June 1, 2007, 2:13pm UTC](https://forum.kirupa.com/t/createemptymovieclip-and-onrollover/227717/1 "2007-06-01T14:13:57Z")

</div>

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:

```auto

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.
