# Problem with simple prototype issue

**URL:** <https://forum.kirupa.com/t/problem-with-simple-prototype-issue/239423>\
**Category:** flash\
**Created:** [September 21, 2007, 3:12pm UTC](https://forum.kirupa.com/t/problem-with-simple-prototype-issue/239423 "2007-09-21T15:12:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hype1](https://avatars.discourse-cdn.com/v4/letter/h/958977/32.png) [@hype1](https://forum.kirupa.com/u/hype1)\
**Post date:** [September 21, 2007, 3:12pm UTC](https://forum.kirupa.com/t/problem-with-simple-prototype-issue/239423/1 "2007-09-21T15:12:19Z")

</div>

Hi there.

I wonder if anyone could help me with (i guess…) a minor issue in using prototypes. I know how to use them on a single movieclip but my problem is that I want to write a prototype that I can use with multiple movieclips stored in an array. That array must be filled with names of movieclips dynamic, because I am going to use a lot. They are named “triangle\_1” and “triangle\_2” and so on… (in this example I’ll stick to three instances)

not working code:

```auto

MovieClip.prototype.myProto = function() {
     this._x += 1;
}

var triangleArray:Array = new Array;

for (i=0; i<3; i++) {
    triangleArray* = "triangle_"+(i+1);
}

onEnterFrame = function(){
    for (i=0; i<triangleArray.length; i++) {
        triangleArray*.myProto();
    } 
}

```

If I don’t add names dynamic to the array, it works. But the I have to type every single movieclip myself (and the beauty of scripting is that it can do a whole lot of work for you). Working script:

```auto

MovieClip.prototype.myProto = function() {
     this._x += 1;
}

var triangleArray:Array = [triangle_1,triangle_2,triangle_3];

onEnterFrame = function(){    
    for (i=0; i<triangleArray.length; i++) {
                triangleArray*.myProto();
            }    
}      

```

I guess it has something to do with the fact that all items in the array are stored as strings, rather then movieclips.

Can anyone explane me what I am doing wrong here?

Greets,

Jeroen
