Action "if" used with several "devices" ?

  • Hi,

    Last post of the day, promise.

    I'd like to give several devices to the action "if", like this

    if(isphone|ispad|istablet+flash, set(plugin[...].x, 0); set(plugin[...].y, 0); );

    Could that be done?

    Thanks. *smile*
    Steph

    Steph

    Edited 2 times, last by esys (March 21, 2012 at 8:56 PM).

  • Hi,

    at the moment there is no OR or AND inside an if(),
    so it would be necessary to use several ifs to do such check,
    but there is also an easy andvery simple solution for this kind of devices check:

    first define a global variable, e.g. "mydevicecheck", for that devices situation and set it to true:

    Code
    <krpano mydevicecheck="true" devices="iphone|ipad|tablet+flash" />

    and then just check this variable in the if:

    Code
    if(mydevicecheck, ...);

    best regards,
    Klaus

  • Hi Nupsi,

    Global var in this case doesn't mean something special, you create a var that you can use in different ways or with different settings.
    It's more understandable with the <events onclick="action();"/> var which is a global one. That means wherever you click the first time in your pano, the action set here will start.

    Hope i've been clear enough. *tongue*

    Steph.

  • Hi,

    I will try to explain too

    Quote

    Could you please explain the "global variable" a little more?

    sorry, that 'global variable' is a term from programming, here it only means an variable that is globally available/accessible,

    e.g. see here - these are the predefined global variables in krpano:
    https://krpano.com/docu/actions/#globalvarsreference

    defining a custom global variable is possible either by defining it at the <krpano> xml level (which is the 'global scope')...
    e.g. either at the root <krpano> node:

    Code
    <krpano ... my_global_var="123">
     ...
    </krpano>

    or anywhere in the xml inside the <krpano> by defining an additionally <krpano> element, e.g.

    Code
    <krpano ...>
      ...
      <krpano my_global_var="123" />
     ...
    </krpano>

    ... or by defining/creating it dynamically by 'setting' it,
    e.g. in an action:

    Code
    set(my_global_var, 123);


    on the other side - 'non-global-variables' or 'local variables' in krpano are the variables from an specific object/element, e.g. the attributes from an <plugin> element, e.g. the "name", "width", "height" ... variables from <plugin> element are variables from the given plugin object,

    to access an plugin local variable, the 'full path' to it, e.g. "plugin[name].width" need to be used - with only one exception - when the action code is called from an plugin event - then the local variables from this plugin object are directly accessible also without path, e.g. when doing: <plugin ... onclick="tween(width,100);" /> the local "width" variable of the current plugin element will be changed,

    best regards,
    Klaus

  • I don't want the thumbnails to be shown on desktop pcs so I tried to use the above variabel/devices combination together with the buildthumbs action, but without success:

    Code
    <krpano mydevicecheck="true" devices="isphone|ispad" />
    ... 
    if(mydevicecheck, buildthumbs(););

    Any ideas why?

    Yours,
    Michael

Participate now!

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