using krpano as a event dispatcher?

  • Hi,

    I rounded up my Interface plugin, now Im trying to create another plugin, a Google Analytics plugin. This plugin needs diffent kinds of information from the interface.

    For example when a hotspot is clicked, krpano sends a event with an id to the interface. The interface does all kinds of stuff (adding a compass, changing textfields etc all based on this id) and then it changes the location.

    I want to send information about, what location people go to, if fullscreen button is pressed etc to Google Analytics plugin. The tricky part is, I dont want to "embed" the GA plugin into the interface. I Just want it as a plugin node in the xml, so I can remove it without rebuilding the Swf. The most information I can derive from either stage event listeners (fullscreen for example) or by the id (what location are people going to). But other stuff happening in the interface, I need to listen to certain events.

    Well as some as you guys might know, communication between 2 different swf's is not that easy. I usually make a globalevents class, dispatch all my events to it, and embed the globalevent class intoo the plugin. I find that a little bit messy for some reason. But then I thought, Hey! Krpano can dispatch events, why not use that instead of a globalevents class. And this is where Im stuck.

    According to the documentation:

    Quote

    example - call a as3/plugin function:
    as3/plugin code: function myfunction(p1:String)
    {
    // ... do something ...
    }

    krpano.set("events.myfu", myfunction);

    xml code: ... onclick="events.myfu(hello from xml);" ...

    But instead of creating a onclick function on a hotspot in the xml, I want a make a call to dispatch the event in the Interface from a function. And in the GA plugin I want the listener.
    But this doesn't seem to work:
    Interface plugin:

    Code
    function somefunction(evt:Event):void
    {
    krpano.call("events.myfu(hello from xml)")
    }

    GA plugin:

    Code
    function myfunction(p1:String)
    {
     krpano.trace(0, p1);
    }
    
    
    krpano.set("events.myfu", myfunction);

    No errors, but nothing happening either. The Event doesn't get triggered in GA. Any ideas? As before, I like to skip xml actions and let flash handle the most part so the xml only has hotspots in it.

  • I solved the problem by creating a localconnection class. However I'm still curious how to create a krpano "event" like above. Btw Something I noticed, I can't seem to listen to the event in both plugins.

    in my xml:
    onclick="events.myfu(hello from xml)"

    in interface fla
    function myfunction(p1:String)
    {
    trace(p1)
    }
    krpano.set("events.myfu", myfunction);

    in GA fla
    function myfunction(p1:String)
    {
    trace(p1)
    }
    krpano.set("events.myfu", myfunction);

    It wil only execute one. First I thought the GA fla wasn't properly registered with krpano, but when I changed one of the hotspots to events.myfu2 and did the same in the fla, it worked. Somehow the event gets removed as soon as it arrives.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!