# Help Calling Function

**URL:** <https://forum.kirupa.com/t/help-calling-function/287208>\
**Category:** flash\
**Created:** [April 28, 2009, 12:31am UTC](https://forum.kirupa.com/t/help-calling-function/287208 "2009-04-28T00:31:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanDaMan](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@DanDaMan](https://forum.kirupa.com/u/DanDaMan)\
**Post date:** [April 28, 2009, 12:31am UTC](https://forum.kirupa.com/t/help-calling-function/287208/1 "2009-04-28T00:31:39Z")

</div>

When I try to use this code to call a function for every instance of a certain class I get an error saying that there is a “call to a possibly undefined method removeInstance through a reference with static type flash.displayObject”. What am I doing wrong?

Here is the code:

```auto

[COLOR=Black]for [/COLOR][COLOR=Black]([/COLOR][COLOR=Black]var i:[/COLOR][COLOR=Black]int=[/COLOR][COLOR=Black]0; i<=numInstances; i++[/COLOR][COLOR=Black]) [/COLOR][COLOR=Black]{
[/COLOR][COLOR=Black] if [/COLOR][COLOR=Black](numInstances!=[/COLOR][COLOR=Black]0&&getChildByName[/COLOR][COLOR=Black]([/COLOR][COLOR=Black]"b"+i[/COLOR][COLOR=Black])!=[/COLOR][COLOR=Black]null[/COLOR][COLOR=Black]) [/COLOR][COLOR=Black]{
                     getChildByName[/COLOR][COLOR=Black]([/COLOR][COLOR=Black]"b"+i[/COLOR][COLOR=Black]).[/COLOR][COLOR=Black]removeInstance[/COLOR][COLOR=Black]([/COLOR][COLOR=Black]);
[/COLOR][COLOR=Black] }
[/COLOR][COLOR=Black]}

```

[/COLOR] [COLOR=#000000] [/COLOR]
