AS 1 and 2 actually do have a strange (buggy?) way to handle function definitions in block statements like for, catch, try, finally and if. As there is no block-level scope in ActionScript we'd expect that function definitions are scoped to the parent timeline / surrounding scope - however they are not:
{ function test(){} trace(test); } Output in AS 1 & 2 : undefined In AS3 however function definitions inside these block statements do behave as expected and are scoped to the surrounding scope (local scope of the function that holds the block or to the timeline the code is on). The output of above sample in AS3 is therefore: function Function() {} Some more info: http://livedocs.macromedia.com/labs/as3preview/docs/00000032.html hth -------------- Andreas Weber -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Weiser Sent: Sonntag, 20. August 2006 18:11 To: Flashcoders mailing list Subject: [Flashcoders] strange scope behaviour Hello, just take a while and try this: function area55() { if (_root) { trace("_root true") function f() { var g; var h; } } //g=0 trace("f "+f) function h() { } function jj() { for (var i in this) { trace(i+" : "+this[i]); } } jj(); } area55(); and this: function area55() { function f() { var g; var h; } //g=0 trace("f "+f) function h() { } function jj() { for (var i in this) { trace(i+" : "+this[i]); } } jj(); } area55(); why the function f is not even seen, after for sure the if statement is true.... MW _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com