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