# Whats wrong with this function?

**URL:** <https://forum.kirupa.com/t/whats-wrong-with-this-function/222530>\
**Category:** flash\
**Created:** [April 14, 2007, 12:42pm UTC](https://forum.kirupa.com/t/whats-wrong-with-this-function/222530 "2007-04-14T12:42:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phena](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@phena](https://forum.kirupa.com/u/phena)\
**Post date:** [April 14, 2007, 12:42pm UTC](https://forum.kirupa.com/t/whats-wrong-with-this-function/222530/1 "2007-04-14T12:42:40Z")

</div>

ActionScript Code:  
[FONT=Courier New][LEFT]\</p\>  
\<p\>function boatdragCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> i++\</p\>  
\<p\> [COLOR=#0000ff]\_root[/COLOR][COLOR=#000000][[/COLOR]båter[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]onPress[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> pressed = true\</p\>  
\<p\> [COLOR=#000000]}[/COLOR]\</p\>  
\<p\> [COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]i \> båtNR[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR] i = [COLOR=#000080]1[/COLOR] [COLOR=#000000]}[/COLOR]\</p\>  
\<p\>[COLOR=#000000]}[/COLOR]\</p\>  
\<p\>  
[/LEFT]  
[/FONT]

båter = an array with movieclip names  
båtNR = length of båter-array  
i = counter  
problem = when i click one of the movieclips in the array, the counter continiues, and that function is only run when pressed == false
