kr-script questions: testing if variable is set?

  • Hi there,

    I have 2 questions today:

    Short story 1: How do I test if a variable is set?
    Longer story 1: I'm trying to have a generic looktohotspot handling implemented to either the hostpost being clicked, or another target hotspot if one is specified. The base structure is like this:

    Code
    <hotspot style="test" name="hs1"  ... target_scene="foobar" target_hotspot="hs2" />
    	<style name="test"
    			onclick="if(get(target_hotspot) === null,looktohotspot(get(name)),looktohotspot(get(target_hotspot))); loadscene(get(target_scene), null, MERGE, BLEND(1));"
     	/>

    I'm not managing to set this right, with either == or === to null, or tying to use a dummy variable (e.g. if(get(target_hotspot)===get(DUMMY))). The looktohotspot to either target, and loadscene actions are working fine, I just can't get the if condition to work properly.


    Question 2: if there a way to access a scene object by name rather than by index? kind of a reverse lookup: have a scene_by_name[name].index as a counterpart to scene[index].name ?

    Thanks!
    Tim.

    n=4102746880;s="";do{s=String.fromCharCode((n&15)+101)+s}while(n>>>=4);alert(s);

  • Hi,

    Short story 1: How do I test if a variable is set?

    use: (without get())

    Code
    if(var === null, trace(var is not set));

    Question 2: if there a way to access a scene object by name rather than by index? kind of a reverse lookup: have a scene_by_name[name].index as a counterpart to scene[index].name ?

    yes, that's possible, each krpano array element have "index" and "name" variables,

    best regards,
    Klaus

Participate now!

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