You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, December 11th 2009, 6:06pm

call a plugin method (function) from the xm

Hello,

I would like from a hotspot call a function in a plugin, and I doesn't work...
For example, I have in my xml :

<hotspot .... onclick="myAction(param)"> ... </hotspot>

and then an action calling my plugin :

<action name="myAction">
plugin[nameOfMyPlugin].executeAFunction(%1);
</action>

The trace panel shows "unknown action command: plugin[main]. executeAFunction"

In my plugin class, my function is public.
Is there something else I should do ?

Thanks for the help.

2

Saturday, December 12th 2009, 8:43pm

Hi,
In my plugin class, my function is public.
Is there something else I should do ?
you need to make your function also public/available to krpano,
e.g.
to add your function to krpano's 'global' scope do just this:

as3:

Source code

1
2
3
4
5
6
7
8
function yourfunction(parameter)
{
  ...
}

...
krpano.set("yourfunction", yourfunction);
...


xml:

Source code

1
... onclick="yourfunction(hello);" ... 



or add the function direct to your plugin[]:

as3:

Source code

1
set("plugin[nameOfMyPlugin].executeafunction", executeAFunction);

or:

Source code

1
2
var pluginobject = krpano.get("plugin[nameOfMyPlugin]");
pluginobject.executeafunction = executeAFunction;


xml:

Source code

1
plugin[nameOfMyPlugin].executeAFunction(%1);


note - when direct adding functions to the plugin object (pluginobject.executeafunction = ...)
they must be lowercase to be callable from krpano xml!


best regards,
Klaus

3

Tuesday, December 15th 2009, 12:30pm

Thank you Klaus,

It works and your answer was very precise.

all the best !

4

Wednesday, January 18th 2012, 7:14pm

I have a very similar problem. I am trying to call a plugin function from xml:

<plugin name="filesave" url="plugins/filesave.swf" />

<action name="savetext_icon_clicked">
plugin[filesave].savefile;
</action>

private function registerPlugin(event:DataEvent) : void {
this.plugin_object = this.krpano.get(event.data);
this.plugin_object.registerattribute("addText", "");
this.plugin_object.registerattribute("clearText", "");

this.plugin_object.savefile = savefilefunction;
return;
}

public function savefilefunction():void
{
fileRef = new FileReference();
fileRef.save(str, "NewFile2.txt");
}

I am getting unknown action: plugin[filesave].savefile; *sad*

5

Wednesday, January 25th 2012, 7:28pm

Hi,

either add - preload="true" - to your plugin - or use the "onloaded" event to make sure that the plugin is already loaded so your added function already there,

if your are loading other pano/scene then also add - keep="true" - to avoid that your plugin will be removed,

best regards,
Klaus