PDA

View Full Version : Calling object reference - solution


naso
12-17-2008, 12:27 AM
Hi guys,

I just worked out how to get a reference to the object calling the method being executed. Here's an example; you may find it handy.


<canvas debug="true">
<debug x="100" y="10" width="700" height="600"/>

<class name="testButton" extends="button">
<method name="report">
<![CDATA[
Debug.write( 'The object being called : ', this.text );
Debug.write( 'Calling object : ', arguments.caller['_dbg_owner'].text );
Debug.write( 'Calling object reference : ', arguments.caller['_dbg_owner'] );
Debug.write( 'Calling object class : ', arguments.caller['superclass'] );
Debug.write( 'Calling object function : ', arguments.caller );
Debug.write( 'Calling object arguments : ', arguments );
Debug.write();
]]>
</method>
</class>

<testButton id="b1" text="Button 1" x="10" y="10" onclick="b2.report( 'b1' )" />
<testButton id="b2" text="Button 2" x="10" y="40" onclick="b1.report( 'b21', 'b22' )" />

</canvas>


Cheers,

Naso.