# onEnterFrame inside prototype doesn't work

**URL:** https://forum.kirupa.com/t/onenterframe-inside-prototype-doesnt-work/160036
**Category:** flash
**Created:** [August 22, 2005, 10:26pm UTC](https://forum.kirupa.com/t/onenterframe-inside-prototype-doesnt-work/160036 "2005-08-22T22:26:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![chic0](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@chic0](https://forum.kirupa.com/u/chic0)
#### Post date: [August 22, 2005, 10:26pm UTC](https://forum.kirupa.com/t/onenterframe-inside-prototype-doesnt-work/160036/1 "2005-08-22T22:26:32Z")

</div>

Check my little piece of code. Everything’s going well, until the onEnterFrame. My MC instances aren’t doin’ anything! ☹  
Can anybody tell me what I’m doin’ wrong?

```auto
colors = [0x66FF00, 0x20DFD0, 0xEE1164, 0xDAE31C];
MovieClip.prototype.drawCube = function(_moveY, _amount) {
    for (i=0; i<_amount; i++) {
        this.createEmptyMovieClip("cube"+i, i);
        this["cube"+i].lineStyle(1, colors[random(4)], 50);
        this["cube"+i].beginFill(0x2a0000, 80);
        this["cube"+i].moveTo(0, 0);
        this["cube"+i].lineTo(5, 0);
        this["cube"+i].lineTo(5, 5);
        this["cube"+i].lineTo(0, 5);
        this["cube"+i].endFill();
        this["cube"+i]._x = random(Stage.width);
        this["cube"+i]._y = Stage.height-7;
        this.onEnterFrame = function() {
            this["cube"+i]._y -= _moveY;
        };
    }
};
drawCube((random(7)+3), 10);

```

Thanks in advance!
