setting a variable from within a plugin - *SOLVED*

  • Hello,

    I'm trying to set/modify a variable of the plugin from within the plugin.
    Somehow it does not have any effect.

    So far I tried to set a variable with the call-function:

    Code
    krpano.call("set(" + plugin_path + ".y, +150);");

    and with the set-function:

    Code
    krpano.set(" + plugin_path + ".y, +150);");

    I even tried the function updatescreen() and invalidatescreen() after setting the variable.

    Can anybody tell me how to do this?

    Greetz,
    Makooze

  • I want to load a picture via a file and then center it in the pano.
    As I don't the dimension of the specified picture I need to calculate
    width and height, then set the new dimension of the plugin.

    I did try the code:

    Code
    plugin = krpano.get(plugin_path);
     plugin.y = 150;
    
    
    krpano.trace(krpano_as3_interface.DEBUG, "plugin.y -" + plugin.y); 
    -- Output y=150

    But it didn't have any effect on the display.
    How do I make changes effective?

    Btw., the change of variable y was just an example.

  • Make sure your <plugin> tag does not include any setting for origin, alignment, scale, position, etc. Or at least that's what klaus said when I had the same problem :P

    In my own photo viewer I kept only the align set to center the plugin and included no movieclips in the plugin (only actionscript) so its effective center was 0. This makes the origin of the plugin's coordinate space the middle of the screen. Then I used this:

    evt.target.content.height = stage.stageHeight * 0.8;
    evt.target.content.width = evt.target.content.width * evt.target.content.height / aux;
    evt.target.content.x = evt.target.content.width / -2.0;
    evt.target.content.y = evt.target.content.height / -2.0;

    (evt.target because it comes from a loader's complete event)

    EDIT: Forgot aux = evt.target.content.height; in the beginning ;)

    Einmal editiert, zuletzt von Protected (8. September 2010 um 19:27)

  • Hi again. it depends on what evt we're talking about! Mine was a Loader's completion event, which was downloading an image from the server, NOT a krpano interface plugin event! I'm glad you figured it out ;)

  • Those work. Also much better:

    plugin = krpano.get(plugin_path);
    plugin.y = 150;

    But WHEN are you trying to do this?

    Yes, but that's not the issue. What I need is to write to the krpano event so both (or more) plugins can access variables in the xml using

    Code
    events.onloadcomplete

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

Jetzt mitmachen!

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