You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

hfeist

Beginner

  • "hfeist" started this thread

Posts: 9

Location: Toronto

Occupation: artist

  • Send private message

1

Thursday, July 30th 2015, 6:20pm

get variable problem

I'm having trouble understanding how variables work

I'd like to use a language cookie to set a variable which I can then use to select which images to display. So to get started I'm testing this code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<action name="startup">		set(language,'EN');	trace(get(language));/>

---

<plugin name="ENbtn" url="ENbtn.png"  align="topright" x="0" y="0" visible="false" onclick="js(setCookie('EN'));" keep="true"/>
 <plugin name="FRbtn" url="FRbtn.png"  align="topright" x="0" y="0" visible="false" onclick="js(setCookie('FR'));" keep="true"/>

---
<scene name="scene_GareRilly_pano" title="GareRilly" onstart="showLanguageBtn();" thumburl="panos/GareRilly_2_pano.tiles/thumb.jpg" lat="" lng="" heading="" >
---

<action name="showLanguageBtn">
	trace(get(language));
	if(language=='FR',
		set(plugin[ENbtn].visible,true);
	,
		set(plugin[FRbtn].visible,true);
	);
</action>



the first trace shows the correct variable but the second trace, inside the action, shows that get(language) is null

I'm baffled...



This post has been edited 4 times, last edit by "hfeist" (Jul 30th 2015, 7:13pm)


hfeist

Beginner

  • "hfeist" started this thread

Posts: 9

Location: Toronto

Occupation: artist

  • Send private message

2

Thursday, July 30th 2015, 11:59pm

I've now got it working by moving the showLanguageBtn() call from the scene onstart

<scene name="scene_GareRilly_pano" title="GareRilly" onstart="showLanguageBtn();" thumburl="panos/GareRilly_2_pano.tiles/thumb.jpg" lat="" lng="" heading="" >



to

<events name="currentpano" onnewpano="showLanguageBtn();" onremovepano="stopsound(bgsnd);"/>


I guess there wasn't enough time for the variable to register

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

3

Friday, July 31st 2015, 5:16am

I don't think there's a good reason to put actions in scenes.
There's a definitely code loading order which you can see what happens when by using traces.

For scene specific action code use <scene onstart=""
besides anything in actions has to be redeclared unless you have keep="true" although I'm not sure it works for actions. Very strange. First time I've seen an action inside a scene.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Similar threads