# Calling functions and functional scope

**URL:** <https://forum.kirupa.com/t/calling-functions-and-functional-scope/97646>\
**Category:** Uncategorized\
**Created:** [December 26, 2003, 10:36pm UTC](https://forum.kirupa.com/t/calling-functions-and-functional-scope/97646 "2003-12-26T22:36:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommythewolfboy](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@tommythewolfboy](https://forum.kirupa.com/u/tommythewolfboy)\
**Post date:** [December 26, 2003, 10:36pm UTC](https://forum.kirupa.com/t/calling-functions-and-functional-scope/97646/1 "2003-12-26T22:36:58Z")

</div>

Hi,

I’m trying to moduralise and optimise some a/s from my Xmas game and have come unstuck when attempting to call a function. I’ve tidied up the code for the penguins (a function for whether they attack, and another for when they are shot), but I’m trying to do similar for the puffins, so I can have a single function that they all call. BUT … I can’t get it to work if I call the function from an onLoad event, within a call-back or from within the clip itself (scope issue?). Strangely though, the same function seems to work correctly for an onEnterFrame event e.g.  
PuffinRight\_mc.OnEnterFrame = resetPuffin;  
or onPress mc event (although this is no use to me but would seem to indicate the function is OK!) …  
I’ve attached the fla.  
Essentially, I need to be able to call the resetPuffin function for several puffins for

1. onLoad
2. from within the if statement once it has gone of this screen (this.\_x \< 50) or
3. from within the puffin mc itself (last a/s frame after it has been shot) …

Can anyone help or suggest an alternative? Thanks!
