Hi,
Please take a look at the code snippet below:
<layer name="ly_kabkee" url="/assets/panda.png"
enabled="false"
edge="center"
align="center"
onleft="tween(rotate, 45,,, onright);"
onright="tween(rotate, 0,,, onleft);"
onloaded="onleft()"
ondestroy="trace('bye for now 1.22.3'); onDestroyElement();"
/>
<action name="onDestroyElement">
trace(get(caller.name));
trace(caller);
stoptween(layer[get(name)].rotate);
</action>
This code is designed to make the layer rotate left and right repeatedly and call the onDestroyElement action when the layer is destroyed.
The issue is that while the onDestroyElement action is properly triggered in Krpano 1.22.3, the caller information or properties like name and url seem to be unavailable when accessed within inline code.
For example:
ondestroy="trace('bye for now 1.22.3'); trace(name); trace(URL)"
Both name and url return no values.
That also effects the stoptween is not working in the onDestroyElement action.
Additionally, when switching scenes, the following warning appears:
WARNING: Unknown action: onleft
This could have been prevented if I properly called the stoptween action before changing scenes.
This seems to happen because the layer’s body element has already been removed.
To address this, I’ve had to define an additional onremovepano action to clean things up. However, my expectation was that the ondestroy event would allow me to write less code by automatically handling cleanup. Unfortunately, it doesn’t seem to pass any caller information, making it less useful in this context.
Am I using the ondestroy event incorrectly, or is there another way to approach this?
Let me know if this works for you!