[Flashcoders] Get Original Variable's Name in Function?
Greetings all, Is it possible to retrieve the name of the variable passed into a function? For instance: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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
Re: [Flashcoders] Get Original Variable's Name in Function?
On 5/30/06, Doug Coning [EMAIL PROTECTED] wrote: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? I guess the easiest way is to pass a string reference: function myFunct(str:String, varName:String){ trace(varName+ has value of +str); } var foo:String = ABC; var moo:String = DEF; myFunct(foo, foo); myFunct(moo, moo); That probably isn't what you're trying to achieve though. What exactly are you trying to do? Tim ___ 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
Re: [Flashcoders] Get Original Variable's Name in Function?
Why would you need to know the variable name? It sounds like something has gone heinously wrong with your code if this need is popping up. Doug Coning wrote: Greetings all, Is it possible to retrieve the name of the variable passed into a function? For instance: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
If I understand you requirements, you are trying to work out where the data was passed to the function... your best bet is to use arguments.callee to work this out. Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Mark Hawley Sent: 30 May 2006 14:10 To: Flashcoders mailing list Subject: Re: [Flashcoders] Get Original Variable's Name in Function? Why would you need to know the variable name? It sounds like something has gone heinously wrong with your code if this need is popping up. Doug Coning wrote: Greetings all, Is it possible to retrieve the name of the variable passed into a function? For instance: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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 ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
I'm trying to create a _root level trace function where I can simply pass a variable to a protoype function and it prints out the variable name and value. Here is the pseudocode for what I want to do: MovieClip.prototype.TraceThis = function(str){ Trace(str.Name + : + str.Value); } var myVar:String = This is my value; TraceThis(myVar); Simple function that would save time when developing by allowing me to just pass a variable and it would spit out both the name and value without me always typing it out (trace(myVar = + myVar). I guess I'm lazy... Doug Coning Senior Web Development Programmer FORUM Solutions, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Tim Stickland Sent: Tuesday, May 30, 2006 8:57 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Get Original Variable's Name in Function? On 5/30/06, Doug Coning [EMAIL PROTECTED] wrote: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? I guess the easiest way is to pass a string reference: function myFunct(str:String, varName:String){ trace(varName+ has value of +str); } var foo:String = ABC; var moo:String = DEF; myFunct(foo, foo); myFunct(moo, moo); That probably isn't what you're trying to achieve though. What exactly are you trying to do? Tim ___ 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 This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
Nothing heinously wrong. See other post for how I'd like to be able to trace the original name of the variable for tracking purposes... Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John Mark Hawley Sent: Tuesday, May 30, 2006 9:10 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Get Original Variable's Name in Function? Why would you need to know the variable name? It sounds like something has gone heinously wrong with your code if this need is popping up. Doug Coning wrote: Greetings all, Is it possible to retrieve the name of the variable passed into a function? For instance: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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 This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
The problem here is, if the variable is not constructed as the property of an object, then the name is not kept. For example: class MyClass { public var pvar:String = fine; public function MyClass() { var lvar:String = not fine; tracethis(lvar); tracethis(pvar); } } While pvar will have its name somewhere in the instanced objects, the lvar will not. This is because flash will drop the naming as its scope is at the function level and so is not important. Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doug Coning Sent: 30 May 2006 14:15 To: Flashcoders mailing list Subject: RE: [Flashcoders] Get Original Variable's Name in Function? Nothing heinously wrong. See other post for how I'd like to be able to trace the original name of the variable for tracking purposes... Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John Mark Hawley Sent: Tuesday, May 30, 2006 9:10 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Get Original Variable's Name in Function? Why would you need to know the variable name? It sounds like something has gone heinously wrong with your code if this need is popping up. Doug Coning wrote: Greetings all, Is it possible to retrieve the name of the variable passed into a function? For instance: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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 This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
I thought I couldn't do it, but wanted to ask before ruling it out... Thanks! Doug Coning Senior Web Development Programmer FORUM Solutions, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Lee McColl-Sylvester Sent: Tuesday, May 30, 2006 9:32 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] Get Original Variable's Name in Function? The problem here is, if the variable is not constructed as the property of an object, then the name is not kept. For example: class MyClass { public var pvar:String = fine; public function MyClass() { var lvar:String = not fine; tracethis(lvar); tracethis(pvar); } } While pvar will have its name somewhere in the instanced objects, the lvar will not. This is because flash will drop the naming as its scope is at the function level and so is not important. Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doug Coning Sent: 30 May 2006 14:15 To: Flashcoders mailing list Subject: RE: [Flashcoders] Get Original Variable's Name in Function? Nothing heinously wrong. See other post for how I'd like to be able to trace the original name of the variable for tracking purposes... Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John Mark Hawley Sent: Tuesday, May 30, 2006 9:10 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Get Original Variable's Name in Function? Why would you need to know the variable name? It sounds like something has gone heinously wrong with your code if this need is popping up. Doug Coning wrote: Greetings all, Is it possible to retrieve the name of the variable passed into a function? For instance: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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 This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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 This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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
[Flashcoders] Get Original Variable's Name in Function?
Is it possible to retrieve the name of the variable passed into a function? function myFunct(str:String):Void { for (var varName in this) { if (this[varName] == str) { trace(varName+: +str); } } } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); // Output foo: ABC moo: DEF OK, this is not really retrieving the name of the variable therefore cannot be trusted... Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
??? That won't work, cus a) it still won't display correct names for local scope variables and b) what if you have two vars with the same value??? Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kenneth Kawamoto Sent: 30 May 2006 16:14 To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Get Original Variable's Name in Function? Is it possible to retrieve the name of the variable passed into a function? function myFunct(str:String):Void { for (var varName in this) { if (this[varName] == str) { trace(varName+: +str); } } } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); // Output foo: ABC moo: DEF OK, this is not really retrieving the name of the variable therefore cannot be trusted... Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
Also, the this[varName] assumes that the variable is a property of this, while local scope variables won't be. Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kenneth Kawamoto Sent: 30 May 2006 16:14 To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Get Original Variable's Name in Function? Is it possible to retrieve the name of the variable passed into a function? function myFunct(str:String):Void { for (var varName in this) { if (this[varName] == str) { trace(varName+: +str); } } } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); // Output foo: ABC moo: DEF OK, this is not really retrieving the name of the variable therefore cannot be trusted... Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
Yeah, cool. But for his purposes, try making a static class of that so it's handy and it won't fly because this changes scope. So not so good when writing other classes. A workaround? I suppose you could use #include to bring that in, or just add that code at the beginning of each file you work on. Neat idea though. I'm all for things that help me be both lazy and efficient. Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Kenneth Kawamoto Sent: Tuesday, May 30, 2006 11:14 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Get Original Variable's Name in Function? Is it possible to retrieve the name of the variable passed into a function? function myFunct(str:String):Void { for (var varName in this) { if (this[varName] == str) { trace(varName+: +str); } } } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); // Output foo: ABC moo: DEF OK, this is not really retrieving the name of the variable therefore cannot be trusted... Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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] Get Original Variable's Name in Function?
Also, the this[varName] assumes that the variable is a property of this, while local scope variables won't be. Yes, this will only work in the situation set in the original posters example. I said cannot be trusted because of that but should have stated clearly. Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
Lazy and efficient? They ruled out slaves long ago ;-) Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: 30 May 2006 16:15 To: Flashcoders mailing list Subject: RE: [Flashcoders] Get Original Variable's Name in Function? Yeah, cool. But for his purposes, try making a static class of that so it's handy and it won't fly because this changes scope. So not so good when writing other classes. A workaround? I suppose you could use #include to bring that in, or just add that code at the beginning of each file you work on. Neat idea though. I'm all for things that help me be both lazy and efficient. Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Kenneth Kawamoto Sent: Tuesday, May 30, 2006 11:14 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Get Original Variable's Name in Function? Is it possible to retrieve the name of the variable passed into a function? function myFunct(str:String):Void { for (var varName in this) { if (this[varName] == str) { trace(varName+: +str); } } } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); // Output foo: ABC moo: DEF OK, this is not really retrieving the name of the variable therefore cannot be trusted... Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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
Re: [Flashcoders] Get Original Variable's Name in Function?
That won't work - for example: var foo:String = ABC; var moo:String = ABC; myFunct(foo); myFunct(moo); // Output foo: ABC foo: ABC On 5/30/06, Kenneth Kawamoto [EMAIL PROTECTED] wrote: Is it possible to retrieve the name of the variable passed into a function? function myFunct(str:String):Void { for (var varName in this) { if (this[varName] == str) { trace(varName+: +str); } } } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); // Output foo: ABC moo: DEF OK, this is not really retrieving the name of the variable therefore cannot be trusted... Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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
RE: [Flashcoders] Get Original Variable's Name in Function?
Er, we've worked that out already ;) Lee -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: 30 May 2006 16:49 To: Flashcoders mailing list Subject: Re: [Flashcoders] Get Original Variable's Name in Function? That won't work - for example: var foo:String = ABC; var moo:String = ABC; myFunct(foo); myFunct(moo); // Output foo: ABC foo: ABC On 5/30/06, Kenneth Kawamoto [EMAIL PROTECTED] wrote: Is it possible to retrieve the name of the variable passed into a function? function myFunct(str:String):Void { for (var varName in this) { if (this[varName] == str) { trace(varName+: +str); } } } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); // Output foo: ABC moo: DEF OK, this is not really retrieving the name of the variable therefore cannot be trusted... Kenneth Kawamoto http://www.materiaprima.co.uk ___ 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 ___ 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
Re: [Flashcoders] Get Original Variable's Name in Function?
Lee, Terribly sorry about that. I'll tell my email delivery system to be a bit faster next time, shall I..? If everyone were to wait to see whether someone else had already replied, nothing would ever get posted. Apologies if, for some reason, it's caused you a problem. Ian On 5/30/06, Lee McColl-Sylvester [EMAIL PROTECTED] wrote: Er, we've worked that out already ;) Lee ___ 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
Re: [Flashcoders] Get Original Variable's Name in Function?
This isn't possible, because local vars typically (that is, in function2 which is used for class methods) become registers in the bytecode, i.e., the name you give a local var won't be included in your SWF *at all*, they are physically missing in the compiled SWF. The old function tag used named variables (getVariable, setVariable), but those string identifiers aren't accessible, either. You can have a look yourself, simply name a var something you don't use for a property anywhere (say, asdasd) and search it in the output of flasm or swfmill. It won't be there. As a simpler test, use a longer name and observe the file size not getting any bigger. Hth, Mark On 5/30/06, Doug Coning [EMAIL PROTECTED] wrote: Greetings all, Is it possible to retrieve the name of the variable passed into a function? For instance: function myFunct(str:String){ // GET ORIGINAL NAME of str? } var foo:String = ABC; var moo:String = DEF; myFunct(foo); myFunct(moo); In the above, how can myFunct know that the first call was sent 'foo' and the second call was sent 'moo'? Thanks, Doug Coning Senior Web Development Programmer FORUM Solutions, LLC This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please reply to sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. ___ 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 -- http://snafoo.org/ key: 1BD689C0 (3801 6F51 4810 C674 1491 ADE7 D8F6 0203 1BD6 89C0) ___ 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