Sie sind nicht angemeldet.

kosmodroms

Anfänger

  • »kosmodroms« ist der Autor dieses Themas

Beiträge: 40

Wohnort: Latvia

Beruf: Kosmodroms | Digital Creative Studio - programmer, designer

  • Nachricht senden

1

Mittwoch, 22. Februar 2012, 15:58

Listen to to KRpano events inside the plugin (SOLVED)

Is there a way to listen to onnewpano event (or any other KRpano event available in XML) inside plugin (both Flash and JS)?
Or the only way is to add function to plugin and call it from XML when event fires ?

By now I use a workaround which works but doesn't look very nice.
AS3 code:

Quellcode

1
2
3
4
5
6
var prevOnNewPano:Function = krpano.get("events.onnewpano");
krpano.set("events.onnewpano", function(){(prevOnNewPano!=null)?prevOnNewPano():null; onNewPano();});

private function onNewPano(...rest):void {
   .......
}

It creates new function which takes current onnewpano function and adds onNewPano call to it.

I also noticed that onnewpano event doesn't fire if image type is QTVR!
Edgars
Kosmodroms | Digital Creative Studio
www.kosmodroms.lv

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »kosmodroms« (13. März 2013, 10:29)


2

Mittwoch, 22. Februar 2012, 17:22

Hi,

you can use named events to avoid overwriting the global ones,

e.g. in the registerplugin function add the events by doing:

Quellcode

1
2
krpano.set("events[myevents].onnewpano", ...);
krpano.set("events[myevents].keep", true);
or

Quellcode

1
2
3
var myevents:* = krpano.events.createItem("myevents");
myevents.onnewpano = ...;
myevents.keep = true;


and in the unloadplugin function remove it by:

Quellcode

1
krpano.set("events[myevents].name", null);
or

Quellcode

1
krpano.events.removeItem("myevents");


and instead of "myevents" you could use a dynamically generated unique name to avoid interferes,
e.g. the plugin name + "_events" or and an random/time-based number,

btw - the createItem and removeItem krpano array functions were documented here:
http://krpano.com/docu/plugininterface/#array.removeItem

I also noticed that onnewpano event doesn't fire if image type is QTVR!
okay, I will check this,

best regards,
Klaus

kosmodroms

Anfänger

  • »kosmodroms« ist der Autor dieses Themas

Beiträge: 40

Wohnort: Latvia

Beruf: Kosmodroms | Digital Creative Studio - programmer, designer

  • Nachricht senden

3

Mittwoch, 22. Februar 2012, 17:34

Thanks!
Edgars
Kosmodroms | Digital Creative Studio
www.kosmodroms.lv

Ähnliche Themen