Danny,
I just ran the following in Flash 8 (AS2) and it worked as expected:
function testArgument(foo:String){
if(foo == undefined) foo = "Foo was not defined";
this.txtField.text += "["+foo+"]";
}
testArgument();
The string, "[Foo was not defined]" was printed in the text field.
-Jim
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Danny
Kodicek
Sent: Tuesday, December 19, 2006 7:53 AM
To: 'Flashcoders mailing list'
Subject: [Flashcoders] Local variables and function arguments
For, well, pretty much ever, I've worked on the assumption that in this
structure:
function myFunc(tVar:String) {
}
the variable tVar was automatically defined in local scope: that is, I can
write
function myFunc(tVar:String) {
if (tVar == undefined) { tVar = "limpet" } }
But you know what? That's not true! I've just discovered (and bear in mind,
I've been using that code structure for years) that I have to declare the
variable:
function myFunc(tVar:String) {
if (tVar == undefined) {var tVar:String = "limpet" } }
That seems really weird to me. Am I wrong? Is there some other explanation?
Danny
_______________________________________________
[email protected]
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
_______________________________________________
[email protected]
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