# OnEnterFrame - attachMovie

**URL:** <https://forum.kirupa.com/t/onenterframe-attachmovie/206956>\
**Category:** flash\
**Created:** [November 13, 2006, 2:58pm UTC](https://forum.kirupa.com/t/onenterframe-attachmovie/206956 "2006-11-13T14:58:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpdp](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@bpdp](https://forum.kirupa.com/u/bpdp)\
**Post date:** [November 13, 2006, 2:58pm UTC](https://forum.kirupa.com/t/onenterframe-attachmovie/206956/1 "2006-11-13T14:58:38Z")

</div>

This should be easy for someone, I’m trying to attach a bunch of movieClips to the stage and have it animate this action using onEnterFrame.

everthing works but i would like all the mc’s to stay on the stage. right now it deletes the old one after it makes a new one.

```auto
var nStage:Number = Stage.width;
var nXpos:Number = 0;
var nCurrent:Number = 0;
onEnterFrame = function () {
    if (nCurrent>=nStage/10) {
        delete this.onEnterFrame;
    } else {
    attachMovie("mcStick", "newStick"+nCurrent, nCurrent);
    ["newStick"+nCurrent]_x = nXpos;
    nXpos += 10;
    _alpha = 10+Math.random()*40;
    _y = random(Stage.height)/2;
    _yscale = 50+Math.random()*100;
    nCurrent += 1;
    }
};

```

any help you could give would be wonderful - thank you
