You are not logged in.

timothee

Beginner

  • "timothee" started this thread

Posts: 6

Location: Singapore

Occupation: Web Developer

  • Send private message

1

Wednesday, December 28th 2011, 4:46pm

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:

Source code

1
2
3
4
	<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);

2

Tuesday, January 3rd 2012, 10:51am

Hi,
Short story 1: How do I test if a variable is set?
use: (without get())

Source code

1
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