[Flashcoders] tracing function calls in AS2

2007-08-24 Thread Hans Wichman
Hi list,

I've been dabbling in the black art of wrapping function calls today, and
seeing the list is now and then visited by questions on how to trace
function names for functions being called and how to insert and take out
debug statements, I've decided to post this here, hopefully it's of use to
someone, otherwise just ignore it:):

http://objectpainters.com/blog/?p=62

Basically assume you have this (excerpt from the post):
var lTestClass:TestClass = new TestClass ();
lTestClass.testMethod(1,2,3);

it that it prints (testMethod calls testMethod2):

This is printed by testMethod
This is printed by testMethod 2
Using the FunctionWrapper, it will print:

= Entering testMethod with arguments 1,2,3
This is printed by testMethod
= Entering testMethod2
This is printed by testMethod 2
= Exiting testMethod2 with no return value.
= Exiting testMethod with return value:I am testMethod's returnvalue

Greetz and a nice weekend to you all!
JC

ps you can specify which trace function to use, eg trace or _global.tt or
whatever.
___
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] tracing function calls

2006-10-17 Thread Vishal Kapur

Thanks, these are all very useful suggestions.  Unfortunately the
3rd-party swf did seem to break when I tried loading it into my own
flash movie so xray may not work for me.  xflas2 is interesting in
that having a general reflection API would be useful in other
contexts.

-- Vishal


On 9/29/06, John Grden [EMAIL PROTECTED] wrote:

and xray uses Hans class resolver ;)

I've had this situation before as well, and what I did was create a base
flash movie that loaded the 3rd parties SWF in.  Xray was in the library and
ready to inspect their swf.  THe only problem with that is something might
break since now, that swf isn't at _level0.  For that, you might try setting
_lockroot = true on the swf that's loaded and go from there.

On 9/29/06, Hans Wichman [EMAIL PROTECTED] wrote:

 Hi,
 there are different options, i think as2lib has some kind of AOP
 mechanisms,
 allowing you to add aspects to your code, eg a logging aspect. Not
 entirely
 sure about this but i think in this case it would come down to walking the
 global tree, through all classes (assuming everything is as2), walking
 through all functions in all classes and wrapping them the way Ray did
 below.

 If you'd use xflas2 (osflash.org/xflas2) with this, the classfinder and
 functionfinder would already have been provided, and you could set a
 FunctionHandler on the FunctionFinder which does the wrapping for you. I
 am
 working on having xflas2 provide the functionality you mention out of the
 box, but for now, you'd have to add it yourself.
 The nice thing with xflas2 though is that you could use:
 Logger.markEntry(arguments);
 instead of
trace({function: prop args: +arguments+});

 and it would trace for example ClassA.methodA called from
 ClassB.methodBwith arguments (1,2,3,4)

 Since I havent gotten to doing myself yet, I can't tell what kind of
 problems you'll encounter and if its possible at all:)
 Another great tool to inspect your movie would be Xray ofcourse (
 osflash.org/xray).

 greetz
 JC

 On 9/29/06, Ray Chuan [EMAIL PROTECTED] wrote:

  Hi,
 
  try this:
 
  function wrapper(obj:Object, prop:String):Void {
  var f:Function = Function(obj[prop]);
  obj[prop] = function() {
 trace({function: prop args: +arguments+});
 return f.apply(obj, arguments);
  }
  }
 
  Let's say you want to wrap around the function Kite.fly:
 
  wrapper(Kite, fly);
 
  You could easily write something that wraps every method.
 
  On 9/28/06, Vishal Kapur [EMAIL PROTECTED] wrote:
   I am trying to debug a third-party flash movie (so I don't have direct
   access to the code, but I can ask them to add small snippets).  What I
   would like to be able to do is to trace the name of a function/method
   and the arguments it is passed upon invocation of that function.  I
   need to be able to do that in a non-intrusive and generic way.
  
   Wondering what people's thoughts are on this.  I can see a couple of
   potential ways this could be done: one, override some internal
   function that is used to make function calls; two, use a function like
   __resolve() that would get called when any defined function is
   invoked.  Anybody know if such things exist?  Or if there is some
   other, simpler way which I'm missing?
  
   Thanks,
   Vishal
   ___
   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
  
 
 
  --
  Cheers,
  Ray Chuan
  ___
  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




--
[  JPG  ]
___
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

Re: [Flashcoders] tracing function calls

2006-09-29 Thread Ray Chuan

Hi,

try this:

function wrapper(obj:Object, prop:String):Void {
 var f:Function = Function(obj[prop]);
 obj[prop] = function() {
   trace({function: prop args: +arguments+});
   return f.apply(obj, arguments);
 }
}

Let's say you want to wrap around the function Kite.fly:

wrapper(Kite, fly);

You could easily write something that wraps every method.

On 9/28/06, Vishal Kapur [EMAIL PROTECTED] wrote:

I am trying to debug a third-party flash movie (so I don't have direct
access to the code, but I can ask them to add small snippets).  What I
would like to be able to do is to trace the name of a function/method
and the arguments it is passed upon invocation of that function.  I
need to be able to do that in a non-intrusive and generic way.

Wondering what people's thoughts are on this.  I can see a couple of
potential ways this could be done: one, override some internal
function that is used to make function calls; two, use a function like
__resolve() that would get called when any defined function is
invoked.  Anybody know if such things exist?  Or if there is some
other, simpler way which I'm missing?

Thanks,
Vishal
___
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




--
Cheers,
Ray Chuan
___
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] tracing function calls

2006-09-29 Thread Hans Wichman

Hi,
there are different options, i think as2lib has some kind of AOP mechanisms,
allowing you to add aspects to your code, eg a logging aspect. Not entirely
sure about this but i think in this case it would come down to walking the
global tree, through all classes (assuming everything is as2), walking
through all functions in all classes and wrapping them the way Ray did
below.

If you'd use xflas2 (osflash.org/xflas2) with this, the classfinder and
functionfinder would already have been provided, and you could set a
FunctionHandler on the FunctionFinder which does the wrapping for you. I am
working on having xflas2 provide the functionality you mention out of the
box, but for now, you'd have to add it yourself.
The nice thing with xflas2 though is that you could use:
Logger.markEntry(arguments);
instead of
  trace({function: prop args: +arguments+});

and it would trace for example ClassA.methodA called from
ClassB.methodBwith arguments (1,2,3,4)

Since I havent gotten to doing myself yet, I can't tell what kind of
problems you'll encounter and if its possible at all:)
Another great tool to inspect your movie would be Xray ofcourse (
osflash.org/xray).

greetz
JC

On 9/29/06, Ray Chuan [EMAIL PROTECTED] wrote:


Hi,

try this:

function wrapper(obj:Object, prop:String):Void {
var f:Function = Function(obj[prop]);
obj[prop] = function() {
   trace({function: prop args: +arguments+});
   return f.apply(obj, arguments);
}
}

Let's say you want to wrap around the function Kite.fly:

wrapper(Kite, fly);

You could easily write something that wraps every method.

On 9/28/06, Vishal Kapur [EMAIL PROTECTED] wrote:
 I am trying to debug a third-party flash movie (so I don't have direct
 access to the code, but I can ask them to add small snippets).  What I
 would like to be able to do is to trace the name of a function/method
 and the arguments it is passed upon invocation of that function.  I
 need to be able to do that in a non-intrusive and generic way.

 Wondering what people's thoughts are on this.  I can see a couple of
 potential ways this could be done: one, override some internal
 function that is used to make function calls; two, use a function like
 __resolve() that would get called when any defined function is
 invoked.  Anybody know if such things exist?  Or if there is some
 other, simpler way which I'm missing?

 Thanks,
 Vishal
 ___
 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



--
Cheers,
Ray Chuan
___
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] tracing function calls

2006-09-29 Thread John Grden

and xray uses Hans class resolver ;)

I've had this situation before as well, and what I did was create a base
flash movie that loaded the 3rd parties SWF in.  Xray was in the library and
ready to inspect their swf.  THe only problem with that is something might
break since now, that swf isn't at _level0.  For that, you might try setting
_lockroot = true on the swf that's loaded and go from there.

On 9/29/06, Hans Wichman [EMAIL PROTECTED] wrote:


Hi,
there are different options, i think as2lib has some kind of AOP
mechanisms,
allowing you to add aspects to your code, eg a logging aspect. Not
entirely
sure about this but i think in this case it would come down to walking the
global tree, through all classes (assuming everything is as2), walking
through all functions in all classes and wrapping them the way Ray did
below.

If you'd use xflas2 (osflash.org/xflas2) with this, the classfinder and
functionfinder would already have been provided, and you could set a
FunctionHandler on the FunctionFinder which does the wrapping for you. I
am
working on having xflas2 provide the functionality you mention out of the
box, but for now, you'd have to add it yourself.
The nice thing with xflas2 though is that you could use:
Logger.markEntry(arguments);
instead of
   trace({function: prop args: +arguments+});

and it would trace for example ClassA.methodA called from
ClassB.methodBwith arguments (1,2,3,4)

Since I havent gotten to doing myself yet, I can't tell what kind of
problems you'll encounter and if its possible at all:)
Another great tool to inspect your movie would be Xray ofcourse (
osflash.org/xray).

greetz
JC

On 9/29/06, Ray Chuan [EMAIL PROTECTED] wrote:

 Hi,

 try this:

 function wrapper(obj:Object, prop:String):Void {
 var f:Function = Function(obj[prop]);
 obj[prop] = function() {
trace({function: prop args: +arguments+});
return f.apply(obj, arguments);
 }
 }

 Let's say you want to wrap around the function Kite.fly:

 wrapper(Kite, fly);

 You could easily write something that wraps every method.

 On 9/28/06, Vishal Kapur [EMAIL PROTECTED] wrote:
  I am trying to debug a third-party flash movie (so I don't have direct
  access to the code, but I can ask them to add small snippets).  What I
  would like to be able to do is to trace the name of a function/method
  and the arguments it is passed upon invocation of that function.  I
  need to be able to do that in a non-intrusive and generic way.
 
  Wondering what people's thoughts are on this.  I can see a couple of
  potential ways this could be done: one, override some internal
  function that is used to make function calls; two, use a function like
  __resolve() that would get called when any defined function is
  invoked.  Anybody know if such things exist?  Or if there is some
  other, simpler way which I'm missing?
 
  Thanks,
  Vishal
  ___
  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
 


 --
 Cheers,
 Ray Chuan
 ___
 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





--
[  JPG  ]
___
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] tracing function calls

2006-09-28 Thread Vishal Kapur

I am trying to debug a third-party flash movie (so I don't have direct
access to the code, but I can ask them to add small snippets).  What I
would like to be able to do is to trace the name of a function/method
and the arguments it is passed upon invocation of that function.  I
need to be able to do that in a non-intrusive and generic way.

Wondering what people's thoughts are on this.  I can see a couple of
potential ways this could be done: one, override some internal
function that is used to make function calls; two, use a function like
__resolve() that would get called when any defined function is
invoked.  Anybody know if such things exist?  Or if there is some
other, simpler way which I'm missing?

Thanks,
Vishal
___
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