# Help with code

**URL:** <https://forum.kirupa.com/t/help-with-code/196031>\
**Category:** Uncategorized\
**Created:** [August 4, 2006, 6:36pm UTC](https://forum.kirupa.com/t/help-with-code/196031 "2006-08-04T18:36:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![habes](https://avatars.discourse-cdn.com/v4/letter/h/e5b9ba/32.png) [@habes](https://forum.kirupa.com/u/habes)\
**Post date:** [August 4, 2006, 6:36pm UTC](https://forum.kirupa.com/t/help-with-code/196031/1 "2006-08-04T18:36:43Z")

</div>

i think that im missing something simple, but i cant seem to find it and its starting to bug me. all im trying to do is create movement for a mc. i had it working on the mc with onClipEvents, but now im trying to transfer it to the frame and kinda make it call its on instance name. maybe this doesnt work at all.

on mc, unit2 (instance name) :

```auto
onClipEvent (load) {
    _x = 5;
    _y = 0;
    speed = 50;
    instance = "_root.unit"+_root.population;
    _root.population += 1;
}
on (release) {
    _root.selectUnit1 = instance;
    _root.selectedUnit1 = true;
}

```

on main frame:

```auto
population = 1;
selectedUnit1 = false;
selectedUnit2 = false;
selectUnit1 = "none";
selectUnit2 = "none";
selectUnit1.onMouseDown = function() {
    if ((_root.selectedUnit1 == true) and (Key.isDown(Key.CONTROL))) {
        endX = _root._xmouse;
        endY = _root._ymouse;
    }
};
selectUnit1.onEnterFrame = function() {
    _x += (endX-_x)/speed;
    _y += (endY-_y)/speed;
    if (_root.selectedUnit1 == true) {
        this.selectRing._visible = true;
    }
    if (_root.selectedUnit1 == !true) {
        this.selectRing._visible = false;
    }
};

```

thanks
