# Var and function help

**URL:** <https://forum.kirupa.com/t/var-and-function-help/210256>\
**Category:** Uncategorized\
**Created:** [December 16, 2006, 9:02pm UTC](https://forum.kirupa.com/t/var-and-function-help/210256 "2006-12-16T21:02:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skellykitten](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@skellykitten](https://forum.kirupa.com/u/skellykitten)\
**Post date:** [December 16, 2006, 9:02pm UTC](https://forum.kirupa.com/t/var-and-function-help/210256/1 "2006-12-16T21:02:50Z")

</div>

I’m trying to write a function that automatically places each new mc I attach, or place on the stage above the other. I’ve been trying this, butit’s not working and I’m confusing my self.

```auto

//next highest depth after specified depth
var nextDepth:Number = 600;
//mc depth placement
var nextMC = "myMC" +nextDepth;

//puts mcs ontop of each other
function mcDepth(){
    _root.attachMovie("myMC", nextMC, nextDepth);
    nextDepth++;
    }

//and then I tried to call it like this:

mcDepth("movieclip1");

```

It doesn’t work. Mostly because I don’t know what I’m doing.  
Can anyone explain why it doesn’t work and what I’m doing wrong?  
I’m soo confused.  
Thanks!
