Sie sind nicht angemeldet.

1

Donnerstag, 27. Mai 2021, 13:19

showtext doesnt work with variable

Hey guys,

I've got a problem with an action for some hotspots. I would like to show some text on hover. Therefor I've got the showtext plugin, problem is that I can't get it to show the text I want.

No matter what combination I'm using for the variable, showtext got the right style but doesnt show any text. As soon as I enter text by hand instead of a variable its working correct. When checking the variable via "trace" I get the correct response, so the variable isnt empty.

Maybe someone could have a look at the action (problem is at line 22 onhover):

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<action name="choose_style" scope="local">
txtsplit(caller.styles, ',', arr); 
set(caller.onclick,remove_style_hotspots(caller.name));

for(set(i,0), i LT arr.count, inc(i), 

txtadd(hstitle, '"', get(scene[get(arr[get(i)].value)].title), '"');
txtadd(hsname, 'hs_style_', get(i));
txtadd(hsurl, '', get(scene[get(arr[get(i)].value)].thumburl));
txtadd(hsposition, calc(view.hlookat),',',calc(view.vlookat),',',calc(view.fov));

addhotspot(get(hsname));

hotspot[get(hsname)].loadstyle(skin_hotspot_choose_style);
set(hotspot[get(hsname)].url, get(hsurl)); 
set(hotspot[get(hsname)].ath, calc(caller.ath));
set(hotspot[get(hsname)].atv, calc(caller.atv));
set(hotspot[get(hsname)].linkedscene, get(arr[get(i)].value));
set(hotspot[get(hsname)].linkedscene_lookat, get(hsposition));
set(hotspot[get(hsname)].onloaded, set_css_id('test'));

set(hotspot[get(hsname)].onhover, showtext(get(hstitle), hotspotTextstyle));

trace(hstitle);

if(xml.scene == arr[get(i)].value, 
tween(hotspot[get(hsname)].alpha, 0.5, 1.2);
tween(hotspot[get(hsname)].scale, 0.38, 0.6);
,
tween(hotspot[get(hsname)].alpha, 1, 1.2);
tween(hotspot[get(hsname)].scale, 0.48, 0.6););

tween(hotspot[get(hsname)].rotate, calc((360/arr.count)*(i+1)), 0.6);
tween(hotspot[get(hsname)].rz, calc(-(360/arr.count)*(i+1)), 0.6);); 
</action>

2

Donnerstag, 27. Mai 2021, 13:38

maybe add a
trace(hotspot[get(hsname)].onhover);
and see what you have in there

also this line has a bracket error
set(hotspot[get(hsname)].onhover, showtext(get(hstitle), hotspotTextstyle));

3

Donnerstag, 27. Mai 2021, 13:54

Thx for your response.

Can you tell where you see the bracket error? I cant find it.

The trace(hotspot[get(hsname)].onhover); outputs:
showtext(get(hstitle), hotspotTextstyle)

4

Donnerstag, 27. Mai 2021, 14:43

ah sorry, bracket error was my mistake... all ok *whistling*

but this : showtext(get(hstitle), hotspotTextstyle) is not ok.

when this executes (onhover) the variable hstitle doesnt exist, thats why you dont get a text.

try this :

calc(hotspot[get(hsname)].onhover, "showtext(" + hstitle + ", hotspotTextstyle)");
trace(hotspot[get(hsname)].onhover);

5

Donnerstag, 27. Mai 2021, 14:58

Awesome, that "hack" works.
But why is it needed? Not really getting it.

6

Donnerstag, 27. Mai 2021, 15:58

its not a hack at all *tongue*

with this : set(hotspot[get(hsname)].onhover, showtext(get(hstitle), hotspotTextstyle));
you write a string "showtext(get(hstitle), hotspotTextstyle)" into the onhover attribute of the hotspot
the onhover action is executed later and has nothing to do with your choose_style(),
in the scope of the onhover action your variable hstitle is unknown / null
hstitle is defined / used in the scope of your action[choose_style] only

if you wouldnt use scope="local" in choose_style() hstitle would be global
but then all hotspots would use the content of the last iteration, which is wrong, too *squint*

... ps: just tested it... this can be really confusing:
set(a,"hello"); trace("a=",a); // hello
set(b,get(a)); trace("b=",b); // hello
set(c,showtext(get(a))); trace("c=",c); // showtext(get(a))
so in #2 get() gets resolved, but not in #3 (if it is nested)

in short: you need to take care when you compose event functions. *cool*

Dieser Beitrag wurde bereits 7 mal editiert, zuletzt von »indexofrefraction« (27. Mai 2021, 16:19)


7

Freitag, 28. Mai 2021, 11:50

Awesome, thanks for the detailied explanation.
*thumbsup*