Re: [Flashcoders] Which object called the function
Not sure if this is a solution in your case, but you could identify the calling function this way... class Main { function Main() { runHello._id = "Main told me to do it..."; runHello(); } function runHello() { var a = new A(); a.hello(); } } class A { function A() {} function hello() { trace("hello"); trace(arguments.caller._id); } } -Danro On Oct 7, 2006, at 8:10 AM, Ramon Miguel M. Tayag wrote: Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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] Which object called the function
Hi, i reread my own post and saw it was a bit short:). In general though this was one of the reasons i wrote xflas2. Since its still in alpha (the alpha part is referring to the documentation or lack of it though, not the state of the code, that is pretty solid now), the easiest is to download it from osflash and try the different examples. In short, you'll need to configure the logger, this is in the examples well. As part of the configuration you'll need to register your classes, through ClassFinder.registerPackage ("mypackage"); The option ClassFinder.registerAll() has not yet been added. Once you have done this, you can use Logger.markEntry(arguments). Lemme know if this works for you or if you'd like any help with it. greetz JC On 10/8/06, Hans Wichman <[EMAIL PROTECTED]> wrote: Hi, use xflas2, from osflash/xflas2 :) And check the examples, there is a Logger.markEntry call which will print: ClassA.methodA called from ClassB.methodB. greetz Hans ps i will put more info up soon On 10/8/06, Troy Rollins <[EMAIL PROTECTED]> wrote: > > > On Oct 8, 2006, at 1:47 AM, Ramon Miguel M. Tayag wrote: > > > Yes, that would work, but is there a way to do it automatically and > > elegantly? > > Remember to always do it until it becomes second nature? ;-) > > This is the way I always do it at least. I don't know of any other > reliable way. > > -- > Troy > RPSystems, Ltd. > http://www.rpsystems.net > > > ___ > 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] Which object called the function
Hi, use xflas2, from osflash/xflas2 :) And check the examples, there is a Logger.markEntry call which will print: ClassA.methodA called from ClassB.methodB. greetz Hans ps i will put more info up soon On 10/8/06, Troy Rollins <[EMAIL PROTECTED]> wrote: On Oct 8, 2006, at 1:47 AM, Ramon Miguel M. Tayag wrote: > Yes, that would work, but is there a way to do it automatically and > elegantly? Remember to always do it until it becomes second nature? ;-) This is the way I always do it at least. I don't know of any other reliable way. -- Troy RPSystems, Ltd. http://www.rpsystems.net ___ 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] Which object called the function
On Oct 8, 2006, at 1:47 AM, Ramon Miguel M. Tayag wrote: Yes, that would work, but is there a way to do it automatically and elegantly? Remember to always do it until it becomes second nature? ;-) This is the way I always do it at least. I don't know of any other reliable way. -- Troy RPSystems, Ltd. http://www.rpsystems.net ___ 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] Which object called the function
Yes, that would work, but is there a way to do it automatically and elegantly? On 10/8/06, Victor Gaudioso <[EMAIL PROTECTED]> wrote: when you call the function have it pass itself in as a parameter: someFunc(this) function someFunc(caller:Object):Void{ trace(caller) } Therefore who ever calls the function will pass itself into the function. That should work. Victor -- Ramon Miguel M. Tayag ___ 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] Which object called the function
when you call the function have it pass itself in as a parameter: someFunc(this) function someFunc(caller:Object):Void{ trace(caller) } Therefore who ever calls the function will pass itself into the function. That should work. Victor - Original Message - From: "Ramon Miguel M. Tayag" <[EMAIL PROTECTED]> To: "FlashCoders Programming" Sent: Saturday, October 07, 2006 11:10 AM Subject: [Flashcoders] Which object called the function Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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] Which object called the function
I then call the function from another timeline. How would I use arguments.caller to return the ID of the object making the call? You can't, at least not directly. arguments.caller will give you a reference to the function from within which your method is called. You can use it to determine if it was called from an instance of a specific class: Say you have a class A with the method foo. From within method bar of class B you want to determine if it was called from an instance of A. You could test that with if( arguments.caller == A.prototype.foo ). However, it won't help you to find out from which instance of class A it was called. HTH, Mark On 10/7/06, Marc Hoffman <[EMAIL PROTECTED]> wrote: Mischa, Can you give a code example of this? Let's say I have this function on the main timeline: someFunction = function(){ // do something; } I then call the function from another timeline. How would I use arguments.caller to return the ID of the object making the call? Thanks, Marc At 09:21 AM 10/7/2006, you wrote: >arguments.caller > >Will give you a reference to the calling function. From the help: > >Property; refers to the calling function. The value of this property >is null if the current function was not called by another function. > >Cheers, > >Mischa > >On 7 Oct 2006, at 17:02, Dr. Suhas Pharkute wrote: > >>Initialise objects with unique ID's which will help you later to >>determine >>which object is calling the function. >> >>Suhas >> >>On 10/7/06, Ramon Miguel M. Tayag <[EMAIL PROTECTED]> wrote: >>> >>>Hi everyone, >>> >>>How do you find out which object calls a particular function? Is it >>>even possible? >>> >>>Let's say there are two classes: >>> >>>class A >>>{ >>> function A(){} >>> >>> function hello() >>> { >>> trace ("hello"); >>> //I want to know who called me, here >>> } >>>} >>> >>>class Main >>>{ >>> var a = new A(); >>> >>> function Main() >>> { >>> a.hello(); >>> } >>>} >>> >>>= >>> >>>How will A know that Main called the function? >>> >>>Thank you, >>>-- >>>Ramon Miguel M. Tayag >>>___ >>>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 >> >> >> >>-- >>Dr. Suhas Pharkute, PhD >>Syna Intelligence, LLP >>V. 208 830 8915 (C) >>E. [EMAIL PROTECTED],.com >>W. http://synaintel.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 > ___ 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] Which object called the function
Mischa, Can you give a code example of this? Let's say I have this function on the main timeline: someFunction = function(){ // do something; } I then call the function from another timeline. How would I use arguments.caller to return the ID of the object making the call? Thanks, Marc At 09:21 AM 10/7/2006, you wrote: arguments.caller Will give you a reference to the calling function. From the help: Property; refers to the calling function. The value of this property is null if the current function was not called by another function. Cheers, Mischa On 7 Oct 2006, at 17:02, Dr. Suhas Pharkute wrote: Initialise objects with unique ID's which will help you later to determine which object is calling the function. Suhas On 10/7/06, Ramon Miguel M. Tayag <[EMAIL PROTECTED]> wrote: Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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 -- Dr. Suhas Pharkute, PhD Syna Intelligence, LLP V. 208 830 8915 (C) E. [EMAIL PROTECTED],.com W. http://synaintel.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 ___ 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] Which object called the function
Yes, Suhas -- but the function is scoped to the timeline in which it was created, not the object doing the calling. So how do you return the ID of the calling object? - Marc At 09:02 AM 10/7/2006, you wrote: Initialise objects with unique ID's which will help you later to determine which object is calling the function. Suhas On 10/7/06, Ramon Miguel M. Tayag <[EMAIL PROTECTED]> wrote: Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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 -- Dr. Suhas Pharkute, PhD Syna Intelligence, LLP V. 208 830 8915 (C) E. [EMAIL PROTECTED],.com W. http://synaintel.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] Which object called the function
arguments.caller Will give you a reference to the calling function. From the help: Property; refers to the calling function. The value of this property is null if the current function was not called by another function. Cheers, Mischa On 7 Oct 2006, at 17:02, Dr. Suhas Pharkute wrote: Initialise objects with unique ID's which will help you later to determine which object is calling the function. Suhas On 10/7/06, Ramon Miguel M. Tayag <[EMAIL PROTECTED]> wrote: Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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 -- Dr. Suhas Pharkute, PhD Syna Intelligence, LLP V. 208 830 8915 (C) E. [EMAIL PROTECTED],.com W. http://synaintel.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] Which object called the function
Initialise objects with unique ID's which will help you later to determine which object is calling the function. Suhas On 10/7/06, Ramon Miguel M. Tayag <[EMAIL PROTECTED]> wrote: Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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 -- Dr. Suhas Pharkute, PhD Syna Intelligence, LLP V. 208 830 8915 (C) E. [EMAIL PROTECTED],.com W. http://synaintel.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] Which object called the function
I'd love to know of a solution to this, too. My hack is to give the function an argument "me": // declaration: traceCaller = function(me){ trace (me); } // function call traces full path of calling object.: traceCaller(this); - Marc Hoffman At 08:10 AM 10/7/2006, you wrote: Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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] Which object called the function
Hi everyone, How do you find out which object calls a particular function? Is it even possible? Let's say there are two classes: class A { function A(){} function hello() { trace ("hello"); //I want to know who called me, here } } class Main { var a = new A(); function Main() { a.hello(); } } = How will A know that Main called the function? Thank you, -- Ramon Miguel M. Tayag ___ 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