# Help please with "Callback" functions

**URL:** <https://forum.kirupa.com/t/help-please-with-callback-functions/63488>\
**Category:** flash\
**Created:** [September 7, 2004, 9:48am UTC](https://forum.kirupa.com/t/help-please-with-callback-functions/63488 "2004-09-07T09:48:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pup\_100](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pup\_100](https://forum.kirupa.com/u/Pup_100)\
**Post date:** [September 7, 2004, 9:48am UTC](https://forum.kirupa.com/t/help-please-with-callback-functions/63488/1 "2004-09-07T09:48:40Z")

</div>

[font=Times New Roman]I’m using a callback function for a button instance’s “onPress” callback event. [/font]

[font=Times New Roman]The function, which is defind within a larger script & in the first frame of the movie, is as follows:[/font]

[font=Times New Roman][color=darkorchid]function move (direction){[/color][/font]

[font=Times New Roman][color=darkorchid]curItem-=direction;[/color][/font]

[font=Times New Roman][color=darkorchid]curItem=Math.min(allProducts.length-1,curItem);[/color][/font]

[font=Times New Roman][color=darkorchid]curItem=Math.max(0,curItem);[/color][/font]

[font=Times New Roman][color=darkorchid]updateDisplay();[/color][/font]

[font=Times New Roman][color=darkorchid]}[/color][/font]

[font=Times New Roman][color=darkorchid]function updateDisplay(){[/color][/font]

[font=Times New Roman][color=darkorchid]description\_txt.text=allProducts[curItem].price;[/color][/font]

[font=Times New Roman][color=darkorchid]}[/color][/font]

[font=Times New Roman][color=darkorchid]back\_btn.onPress=move(1);[/color][/font]

[font=Times New Roman]All this does, when I test the movie, is put the amount for the first item in the array that I’m addressing in the text box – But this happens before any button is pressed & as soon as the movie loads.[/font]

[font=Times New Roman]I have placed the same function call actually on the button instance & it works fine.[/font]

[font=Times New Roman]Any ideas please.[/font]

[font=Times New Roman](Complete fla attached for full script info.)[/font]

---

<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:** [September 7, 2004, 3:13pm UTC](https://forum.kirupa.com/t/help-please-with-callback-functions/63488/2 "2004-09-07T15:13:44Z")

</div>

Use this code instead:

```auto
back_btn.onPress=function(){
move(1);
}

```

---

<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:** [September 7, 2004, 8:05pm UTC](https://forum.kirupa.com/t/help-please-with-callback-functions/63488/3 "2004-09-07T20:05:58Z")

</div>

Thanks claudio works a dream - But how come my original version works most of the time (in other scripts) but not in this case?
