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.
___
[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
--
http://snafoo.org/
key: 1BD689C0 (3801 6F51 4810 C674 1491 ADE7 D8F6 0203 1BD6 89C0)
___
[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
Re: [Flashcoders] Get Original Variable's Name in Function?
Hi Doug,
I tried to do something like this a while back. I didn't know enough
about prototype based languages to get it working. Now that I know more
I think you may be able to do it but you would have to find a back into
the scope you were in when you called it. Here are a couple of things to
keep in mind:
1. since AS2 is a prototype based language you could possibly create a
new Function prototype. When the the function is created you would keep
a reference to its local scope. Then in your TraceMe function you would
use something like this:
function TraceMe(myVariableName) {
var strOut = myVariableName + ":" +
arguments.caller.myscope["myVariableName"];
trace(strOut);
}
You could also try creating the scope reference in the Delegate class.
2. You would also use the ASSetPropFlags to be able to see hidden
variables and make unwritable functions or variables writable.
3. You may find some ways to get to the local scope in the
mx.utils.Delegate class.
I don't really have time to do this obviously, which is why I'm passing
this info on to you but it may be possible.
Here is the class I made that I have used for tracing things,
http://www.judahfrangipane.com/?p=16. It's early work but it works.
Judah
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.
___
[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
--
"Always bear in mind that your own resolution to succeed is more important than any
one thing."
"You can have anything you want - if you want it badly enough. You can be anything you want to be, do anything you set out to accomplish if you hold to that desire with singleness of purpose."
- Abraham Lincoln
___
[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
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 ___ [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
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
>
> ___
> [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
___
[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
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
___
[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
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: [email protected] >>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 >> ___ [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
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: [email protected] >>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 >> ___ [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
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: [email protected] 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 ___ [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
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: [email protected] 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 ___ [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
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.
> > > ___
> > > [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
>
> 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.
> ___
> [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
&g
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.
> > ___
> > [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
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.
___
[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
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.
> > ___
> > [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
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.
___
[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
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
> ___
> [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
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.
___
[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
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.
> ___
> [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
___
[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
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.
___
[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
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
___
[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

