# \[AS2\] MovieClip.Prototype

**URL:** https://forum.kirupa.com/t/as2-movieclip-prototype/223043
**Category:** flash
**Created:** [April 19, 2007, 12:27am UTC](https://forum.kirupa.com/t/as2-movieclip-prototype/223043 "2007-04-19T00:27:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![decumbo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/decumbo/32/1890_2.png) [@decumbo](https://forum.kirupa.com/u/decumbo)
#### Post date: [April 19, 2007, 12:27am UTC](https://forum.kirupa.com/t/as2-movieclip-prototype/223043/1 "2007-04-19T00:27:22Z")

</div>

> 

\_level0.workspace.x0y0 x: 0 y: 0 depth: 2  
x: undefined y: undefined depth: 2  
\_level0.workspace.x0y1 x: 16 y: 0 depth: 3  
x: undefined y: undefined depth: 3  
\_level0.workspace.x0y2 x: 32 y: 0 depth: 4  
x: undefined y: undefined depth: 4  
\_level0.workspace.x0y3 x: 48 y: 0 depth: 5  
x: undefined y: undefined depth: 5  
etc…

```auto

// selectedTile is a global variable
MovieClip.prototype.worktileFunctionality = function(tile:MovieClip) {
    drawTerrainTile(this, tile);
    this.onPress = function () {
        drawTerrainTile(this, selectedTile);
    }
}

function setupWorkspace(map:Array, workspace:MovieClip) {
    var depth = 1;
    for (var i = 0; i < 25; ++i) {
        for (var j = 0; j < 25; ++j) {
            workspace.createEmptyMovieClip("x"+i+"y"+j, depth);
            depth++;
            worktile = workspace["x"+i+"y"+j];
            
            worktile._x = j*16;
            worktile._y = i*16;
            
            tileNum = map*[j][0]-1;
            tile = terrainTiles[tileNum];
            
            trace(worktile+" x: "+worktile._x+" y: "+worktile._y+" depth: "+depth);
            // defined
            
            worktile.worktileFunctionality(tile);
            
            trace(worktile+" x: "+worktile._x+" y: "+worktile._y+" depth: "+depth);
            // undefined?
        }
    }
}

```

What am I doing wrong with this prototype? :h:
