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):

  • 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)

  • 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);

  • 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*

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!