I'm trying to develop a plugin, which has subnodes in its definition in krpano XML, for example it will be defined like this:
(
<plugin name= "PluginName" url="PluginURL.swf"
<!--some attributes-->
>
<point name="PointName1" <!--some attributes-->/>
<point name="PointName1" <!--some attributes-->/>
</plugin>
)
But I don't know how to get the childnodes in the ActionScript when the plugin is registered and REGISTEREVENT is triggered.
Thanks In Advance.
Develop Plugins with subnodes
-
-
Hi,
when you have the got plugin object in the REGISTER EVENT you can directly access the child nodes, either via the krpano get function or directly,
here an example for direct access:
Code
Display Morekrpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent); ... private function registerEvent(evt:DataEvent):void { var pluginobject:Object = krpano.get(evt.data); var pointarray:Array = pluginobject.point.getArray(); var i,cnt; cnt = pointarray.length; for(i=0; i<cnt; i++) { var point:Object = pointarray[i]; trace(point.name); trace(point.someattribute); } }
best regards,
Klaus -
Hi Klaus!
How to access attribute "name"?
I get "undefined"
Thank you!Code<plugin name="parent" > <child name="test" /> <children names="test" /> </plugin> <javascript> alert(plugin.child.name); // undefined alert(plugin.children.names); // test </javascript>
UPD.
One can thus:
But it is not dynamic...UPD.
I found the solution: -
Hi,
note - 'name' is a special attribute - it will create an array:
https://krpano.com/docu/xml/#name-notesbtw - 'children' is already a predefined setting, so declaring a sub-element with that name might be problematic:
https://krpano.com/docu/xml/#layer.childrenBest regards,
Klaus -
Thanks Klaus!
I'm trying to make a <itemstyle name="default" /> for the child items.
But when the style has a name in the xml - can not be set registerattribute.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!