multiple plugins and set/get variable problem *SOLVED*

  • I'm using the set command to store a variable with the name of the current scene so I can get it from within some plugins I'm developing.

    I'm setting it on each scene like this:

    Code
    <scene name="scene1" onstart="set(sname,scene1);">
    ...
    </scene>

    and I'm reading this variable via AS3 on the onloadcomplete event handler function:

    Code
    function updateSceneName():void
    {	
        scene = krpano.get("sname");
    ...
    }

    This works perfectly and I have it working with one plugin. The problem I've hit is when I use the same behaviour on another loaded plugin. Only one of the plugins gets the variable value. I've tried to load them individually and they work ok, but never together. It's like the variable value is lost when it's read by one plugin.

    Can anyone help me out on this? Want am I doing wrong? *confused*

    Thanks,

    ––––•(-• zyON •-)•––––

    Einmal editiert, zuletzt von zyON (3. September 2010 um 20:07)

  • I'm bumping this one. I'm still having the same problem, I've tried to change plugins orders, adding more variables (so each plugin would read a different one) but nothing is working here. Anyone out there? *unsure*

    ––––•(-• zyON •-)•––––

  • If you have two different scenes with two different variables with two different names, I don't see how one could possibly be influencing the other. Are they two different instances of the *same* plugin?

  • If you have two different scenes with two different variables with two different names, I don't see how one could possibly be influencing the other. Are they two different instances of the *same* plugin?


    Not 2 differente scenes, because I need to check for the actual scene, but yeah, 2 different variables with two different names and two different plugins (they're not the same plugin, but they work the same way, of course, with different names).

    ––––•(-• zyON •-)•––––

  • Hi,

    are you maybe trying to use two onloadcomplete events? (there can be only one),

    best regards,
    Klaus

    Klaus, thanks for your reply. Yeah I'm using an event handler in both plugins:

    Code
    krpano.set("events.onloadcomplete", updateSceneName);


    I see what you mean, it makes sense, but how can I use that event in both plugins? Setting it on the XML in a <event> node??? (I'm really guessing here).

    ––––•(-• zyON •-)•––––

  • Hi,

    yes, by setting the event you overwrite it each time,

    if you want an automatic way, add the updateSceneName function to your plugin,
    and then "add" the call of that function to the event,

    e.g.
    use a "PLUGINEVENT_REGISTER" event in your plugin,
    and there get the plugin object and set your function:

    when doing it in that why, the same plugin can be used several times,

    best regards,
    Klaus

  • *EDITED*

    Klaus,

    I think there's a mistake in the last line of your code, it should be a set function not a get, right?

    Code
    krpano.set("event.onloadcomplete", currentonloadevent);

    Also, we should be appending to the string of the onloadcomplete event, right?

    Code
    currentonloadevent += plugin_path + ".updateSceneName();";

    But it seems like it's not able to append the function calls to the event. When I put two plugins (same code, different name), only one of them is able to write to the event string!! Also if I have already an event set in the XML, they just don't append to it. *confused*

    Right now I have something like this:

    ––––•(-• zyON •-)•––––

    3 Mal editiert, zuletzt von zyON (3. September 2010 um 19:54)

  • You forgot

    plugin_object.updatescenename = this.updateSceneName;


    in the registerEvent function.

    Yes, thanks, I deleted it by mistake when I was pasting my code in the forum textarea.

    I've updated the post with my last corrections (like the name of the event handler function in lowercase). Getting near but still not solved! Waiting for Klaus to shed some more light into this one. *rolleyes*

    ––––•(-• zyON •-)•––––

  • Just a couple of minutes seconds of posting my last message I took a quick look and found out the problem... it's event and not events the name of the node!

    The corrected code line should look like this:

    Code
    var currentonloadevent:String = krpano.get("events.onloadcomplete");

    Thanks Klaus!

    +1 for the KRpano support!

    ––––•(-• zyON •-)•––––

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!