# Incrementing Function

**URL:** <https://forum.kirupa.com/t/incrementing-function/196194>\
**Category:** flash\
**Created:** [August 6, 2006, 5:49pm UTC](https://forum.kirupa.com/t/incrementing-function/196194 "2006-08-06T17:49:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Purple\_Elite](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/purple_elite/32/2629_2.png) [@Purple\_Elite](https://forum.kirupa.com/u/Purple_Elite)\
**Post date:** [August 6, 2006, 5:49pm UTC](https://forum.kirupa.com/t/incrementing-function/196194/1 "2006-08-06T17:49:52Z")

</div>

Maybe I’m too tired to be doing this. I am trying to make a simple function that will increment a variable by one and return the new number. I want to use it to assign depths. I just want to start at 0, increment with each call of the function, and have the function return the value of the variable. I have tried about 20 variations of this:

```auto
var currDepth:Number = 0;
function setDepth() {
currDepth++;
return currDepth;
}

```

or

```auto
var currDepth:Number = 0;
function setDepth() {
var thisDepth:Number = currDepth;
currDepth++;
return thisDepth;
}

```
