You are not logged in.

mauma

Beginner

  • "mauma" started this thread

Posts: 24

Location: Lucca - Italy

Occupation: Photographer / Virtual Tour

  • Send private message

1

Monday, May 4th 2020, 5:44pm

caller.sprite.style Loop

hi I wanted to know if it is possible to make a loop for assigning css styles.
I tried but it enters the same name for all DIV
My code

Source code

1
2
3
4
5
6
7
<events name="start_event" keep="true" onxmlcomplete="create_css();"/>

<action name="set_css_class" type="Javascript">  caller.sprite.className = args[1];</action>

<action name="create_css" >
  for(set(i,0), i LT hotspot.count, inc(i),
    if( hotspot[get(i)].style == "my style",  set(name_spot, get(hotspot[get(i)].name));  set(hotspot[get(name_spot)].onloaded, set_css_class(get(name_spot));  maker(get(name_spot)););        );  );  </action>



Results: I have 3 Spots, but all <div> have same Class name ( last hotspot name, count in loop)


Thanks
mauma

2

Monday, May 4th 2020, 6:29pm

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<events name="start_event" keep="true" 
	onxmlcomplete="create_css();" />

<action name="set_css_class" type="Javascript">
	caller.sprite.className = args[1];
</action>

<action name="create_css">
	for(set(i,0), i LT hotspot.count, inc(i),
		if(hotspot[get(i)].style === 'my style',  
			// V1: set action in quotes to not execute the get() here. it will be executed onloaded in hotspot scope 
			set(hotspot[get(i)].onloaded, 'set_css_class(get(name));maker(get(name));'); 
			// V2: use calc to create the action with hardcoded hotspot name
			// calc(hotspot[get(i)].onloaded, 'set_css_class('+hotspot[get(i)].name+');maker('+hotspot[get(i)].name+');'); 
		); 
	);  
</action>


maybe this works

mauma

Beginner

  • "mauma" started this thread

Posts: 24

Location: Lucca - Italy

Occupation: Photographer / Virtual Tour

  • Send private message

3

Tuesday, May 5th 2020, 11:22am

Thanks a lot indexofrefraction, it works!
Regards *smile*
mauma