# Function problems

**URL:** <https://forum.kirupa.com/t/function-problems/9320>\
**Category:** Uncategorized\
**Created:** [December 9, 2002, 7:42pm UTC](https://forum.kirupa.com/t/function-problems/9320 "2002-12-09T19:42:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackpulp](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blackpulp/32/81_2.png) [@blackpulp](https://forum.kirupa.com/u/blackpulp)\
**Post date:** [December 9, 2002, 7:42pm UTC](https://forum.kirupa.com/t/function-problems/9320/1 "2002-12-09T19:42:48Z")

</div>

okay heres my deal, im trying to create my first function and then calling it, but nothing is happening.

heres my function: (on frame 1 of a seperate layer)

function movePics(newPos, rate2) {  
currentY2 = this.\_y;  
distance2 = newPos-currentY2;  
move2 = distance2/rate2;  
this.\_y = currentY2+move2;  
}

and heres where i call the function: (located on a button of course)

on (release) {  
\_root.pic.pics.movePics(500,4);  
}

so, at run time i press the button and nothing happens to that instance? any help would be much appreciated

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 9, 2002, 8:01pm UTC](https://forum.kirupa.com/t/function-problems/9320/2 "2002-12-09T20:01:52Z")

</div>

You can’t use “this” in a function… Try something like this…

```auto

function movePics(mc, newPos, rate2) {
currentY2 = mc._y;
distance2 = newPos-currentY2;
move2 = distance2/rate2;
mc._y = currentY2+move2;
}

```

```auto

on (release) {
_root.movePics(_root.pic.pics, 500,4);
}

```
