# Object/function scope question

**URL:** <https://forum.kirupa.com/t/object-function-scope-question/252899>\
**Category:** Uncategorized\
**Created:** [February 25, 2008, 6:38am UTC](https://forum.kirupa.com/t/object-function-scope-question/252899 "2008-02-25T06:38:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lowpass](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lowpass](https://forum.kirupa.com/u/lowpass)\
**Post date:** [February 25, 2008, 6:38am UTC](https://forum.kirupa.com/t/object-function-scope-question/252899/1 "2008-02-25T06:38:25Z")

</div>

Hello.

I have what I can only assume is a stupid question, but I can’t find a satisfactory answer.

I need to bring an AS 1.0/2.0 project up to AS 3.0 standards in a reasonable timeframe. In the original project, it was common practice to group related functions under descriptive parent objects, such as chatO.pushMessage(), chatO.displayPrompt() and so on.

However, I’m running into a problem where the very simple definition (formatted to be concise):  
[INDENT]a:Object = {};  
a.f1 = function() { var i:Number=1; trace(i); };  
a.f2 = function() { var i:Number=2; trace(i); };  
[/INDENT]generates this error upon compiling:  
[INDENT]1151: A conflict exists with definition i in namespace internal.  
[/INDENT]  
Assigned named functions seem to work…  
[INDENT]function f1() { var i:Number=0; };  
function f2() { var i:Number=0; };  
var b:Object = {};  
b.f1 = f1;  
b.f2 = f2;  
[/INDENT]… generates no errors.

I know that the two types of function declaration are not equivalent. But I don’t understand why the two different functions in the first example share the same scope. Tests with our code suggest that going ahead with assigning named functions should work, but I already feel uncomfortable proceeding with a weak understanding of what was broken in the first place.

Any insight would, of course, be greatly appreciated.

Thank you,  
-Lowpass
