You are not logged in.

Yanward

Beginner

  • "Yanward" started this thread

Posts: 17

Location: Singapore

Occupation: Software Engineer

  • Send private message

1

Thursday, December 22nd 2016, 4:58am

problem with dynamically create hotspot onclick

Hi All,

i'm having a problem regarding on onclick on dynamically created hotspot:


<datavtourbuilding name="bldg1" country="country1" city="city1" />
<datavtourbuilding name="bldg2" country="country1" city="city1" />
<datavtourbuilding name="bldg3" country="country1" city="city1" />
<datavtourbuilding name="bldg4" country="country1" city="city1" />
<datavtourbuilding name="bldg5" country="country1" city="city1" />

for(set(bldg,0), bldg LT datavtourbuilding.count, inc(bldg),
txtadd(bldgname,'bldg_',get(bldg));
txtadd(bldgurl,'/office/',get(datavtourbuilding[get(bldg)].country),'/',get(datavtourbuilding[get(bldg)].city),'/',get(datavtourbuilding[get(bldg)].name),'/',get(datavtourbuilding[get(bldg)].name),'.jpg');
txtadd(bldgtour,'/office/',get(datavtourbuilding[get(bldg)].country),'/',get(datavtourbuilding[get(bldg)].city),'/',get(datavtourbuilding[get(bldg)].name),'/index.html');
addhotspot(get(bldgname));
set(hotspot[get(bldgname)].style,VR_Menu_Style);
set(hotspot[get(bldgname)].keep,'true');
set(hotspot[get(bldgname)].url,get(bldgurl));
set(hotspot[get(bldgname)].rx,0);
set(hotspot[get(bldgname)].ath,get(asd1));
set(hotspot[get(bldgname)].atv,0);
set(hotspot[get(bldgname)].depth,1500);
set(hotspot[get(bldgname)].scale,1);
set(hotspot[get(bldgname)].distorted,'true');
set(hotspot[get(bldgname)].alpha,1);
set(hotspot[get(bldgname)].zorder,2);
set(hotspot[get(bldgname)].onover,tween(scale|hotspot[VR_Hover].alpha|hotspot[VR_Hover].scale|hotspot[VR_Text].alpha,1.1|1|1.1|1);set(hotspot[VR_Hover].ath,get(ath));set(hotspot[VR_Text].ath,get(ath)););
set(hotspot[get(bldgname)].onout,tween(scale|hotspot[VR_Hover].alpha|hotspot[VR_Text].alpha,1|0|0);tween(hotspot[VR_Hover].scale,1,0.01););
set(hotspot[get(bldgname)].onclick,openurl(get(bldgtour),_self););
set(asd1,calc(asd1+30));
);

all hotspot should have different name, url and onclick, but onclick ended having the same string in all hotspot.

thanks *smile*
Yanward *squint*

Alexey Tkachenko

Professional

Posts: 770

Location: Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

2

Thursday, December 22nd 2016, 10:17am

Replace your code with this:

Source code

1
txtadd(hotspot[get(bldgname)].onclick, 'openurl(', get(bldgtour), ',_self);');



The problem was that you need to retrieve bldgtour inside for(); cycle, and not from the click event of the hotspot.
Regards,

Alexey