You are not logged in.

1

Friday, June 10th 2016, 11:35am

jumping through hoops (getting the caller in script language)

hi,

does anybody know if getting the caller is possible in the script language?

see this example:

<!-- setup -->
<layer name="x1" property="y1">
<layer name="x2" property="y2">
<action name="testaction">trace("%0 %1");</action>

<!-- dynamically add action to multiple layers -->
set(layer[x1].myaction, "test(%%1);");
set(layer[x2].myaction, "test(%%1);");

<!-- calling the actions with an argument-->
layer[x1].myaction('testarg');
layer[x2].myaction('testarg'');

console output :
> INFO: testaction testarg
> INFO: testaction testarg

this works so far...
but, is there any way to know in myaction if it was called from layer[x1] or layer[x2] ?
and then to get the callers property y1 respectively y2 ?
or is this only working in js actions?
and...
are events (like onclick) behaving different than a custom action like here?

best,
index

This post has been edited 1 times, last edit by "indexofrefraction" (Jun 10th 2016, 11:47am)


2

Friday, June 10th 2016, 10:40pm

ok... after loads of testing i answer my question myself :

<!-- setup -->
<layer name="x1" property="y1">
<layer name="x2" property="y2">
<action name="test">trace(%0, " ", name, " ", property);</action>

<!-- dynamically add action to multiple layers -->
set(layer[x1].onover, "test();");
set(layer[x2].onover, "test();");

<!-- behavior of actions when onover event is triggered -->
> INFO:test x1 y1
> INFO: test x1 y1

--> reading the layers properties works for layer events
--> like this it is possible to use generalized functions
--> which act on their layers information.

BUT

--> for custom functions added to layers
--> reading the layers properties is not possible


<!--example -->
set(layer[x2].customaction, "test();");

This post has been edited 3 times, last edit by "indexofrefraction" (Jun 13th 2016, 5:46pm)