Glad you got it working tuur!
Here's a different approach that you might find useful. I too found that the image would dissappear if you used an action to write the contents of a data field. I'm still not sure I understand how to get around that issue. Are you using full blown url paths to remedy the problem?
At any rate, here's a solution that does what you asked for and seems to preserve the images as well. It allows you to put get statements in a data node, and automatically replace the get statements with the values of the variable. I've taken the liberty of including an example using your html data node:
<data name="thumb1">
<p align="middle"><font face="Verdana" size="11"><textformat leftmargin="" rightmargin="">
<img src="../thumbs_lanterna/lanterna1.jpg" height="" width="" align="top"/>
here i like to have something like :
the language is get(language) <br/> <b> get(phrase[thumb1].language[get(language)].text) </b><br/>
but then that it works.. ??
</textformat></font></p>
</data>
Note that there is both a simple get statement (get(language)), and a very complicated one (get(phrase[thumb1].language[get(language)].text) embedded in the html. The second get statment accesses the appropriate language via an associative array I'll describe later.
First, the following javascript needs to be included in your tour:
function kr_eval_get_in_string(varname) {
var krpano=document.getElementById("krpanoSWFObject");
var content= krpano.get(varname);
var subs = content.match(/get\((?:[^()]+|\(([^()]+|\(([^()]+|(\([^()]+\)))*\))*\))+\)/g); /* deals with up to 4 sets of nested parenthesis */
var name;
var val;
var i;
for (i=0;i < subs.length;i++)
{
name=subs[i].replace(/^get\(/,"");
name=name.replace(/\)$/,"");
val=kr_resolve(name);
content=content.replace(subs[i],val);
}
krpano.set(varname,content);
}
function kr_resolve(argument) {
var krpano=document.getElementById("krpanoSWFObject");
var subs = argument.match(/get\((?:[^()]+|\(([^()]+|\(([^()]+|(\([^()]+\)))*\))*\))+\)/g); /* deals with up to 4 sets of nested parenthesis */
var name;
var val;
var i;
if (subs != null) {
for (i=0;i < subs.length;i++)
{
name=subs[i].replace(/^get\(/,"");
name=name.replace(/\)$/,"");
val=kr_resolve(name);
argument=argument.replace(subs[i],val);
}
return(krpano.get(argument));
} else {
return(krpano.get(argument));
}
}
Display More
These functions allow you to place get() statements inside your data node, and then replace them with their values on demand simply by calling kr_eval_get_in_string with the argument data[thumb1].contents.
I'm including an example that shows how you can build an associative array to manage the language customization.
<phrase name="thumb1" >
<language name="dutch" text="goedemorgen" />
<language name="english" text="good morning" />
<language name="spanish" text="buenas días" />
<language name="japanese" text="ohayou gozaimasu" />
<language name="french" text="bonjour" />
<language name="german" text="guten morgen" />
<language name="pig_latin" text="oodgay orningmay" />
</phrase>
Note that by using this approach you can handle multiple languages in the onhover event for with a relatively clean xml command:
<plugin name="foo"
...
onhover="showtext(get(phrase[get(name)].language[get(language)].text)"
...
Here we access the appropriate associative array by naming it with the same name as the plugin, then we access the appropriate language using a global variable named language.
Here's a working example xml file that allows you to change the language on-the-fly using a combobox selector. Note that the default language value is set in the first line:
<krpano language="dutch" >
<preview type="grid(cube,16,16,512,0xCCCCCC,0x333333,0x999999);" details="16" />
<phrase name="thumb1" >
<language name="dutch" text="goedemorgen" />
<language name="english" text="good morning" />
<language name="spanish" text="buenas días" />
<language name="japanese" text="ohayou gozaimasu" />
<language name="french" text="bonjour" />
<language name="german" text="guten morgen" />
<language name="pig_latin" text="oodgay orningmay" />
</phrase>
<phrase name="thumb2" >
<language name="dutch" text="goede middag" />
<language name="english" text="good afternoon" />
<language name="spanish" text="buenas tardes" />
<language name="japanese" text="konnichiwa" />
<language name="french" text="bonjour" />
<language name="german" text="guten tag" />
<language name="pig_latin" text="oodgay afternoonway" />
</phrase>
<phrase name="thumb3" >
<language name="dutch" text="goede middag" />
<language name="english" text="good evening" />
<language name="spanish" text="buenas noches" />
<language name="japanese" text="konbanwa" />
<language name="french" text="bonsoir" />
<language name="german" text="guten abend" />
<language name="pig_latin" text="oodgay eveningway" />
</phrase>
<phrase name="thumb4" >
<language name="dutch" text="goede nacht" />
<language name="english" text="good night" />
<language name="spanish" text="buenas noches" />
<language name="japanese" text="oyasumi nasai" />
<language name="french" text="bonne nuit" />
<language name="german" text="gute nacht" />
<language name="pig_latin" text="oodgay ightnay" />
</phrase>
<action name="update_thumb">
if (data[%1].orig === null,
copy(data[%1].orig,data[%1].content);
<!--else-->,
copy(data[%1].content,data[%1].orig);
);
js("kr_eval_get_in_string(data[%1].content);");
txtadd(plugin[%1].html,"data:",%1);
</action>
<data name="thumb1">
<p align="middle"><font face="Verdana" size="11"><textformat leftmargin="" rightmargin="">
<img src="../thumbs_lanterna/lanterna1.jpg" height="" width="" align="top"/>
here i like to have something like :
the language is get(language) <br/> <b> get(phrase[thumb1].language[get(language)].text) </b><br/>
but then that it works.. ??
</textformat></font></p>
</data>
<data name="thumb2">
<p align="middle"><font face="Verdana" size="11"><textformat leftmargin="" rightmargin="">
<img src="../thumbs_lanterna/lanterna1.jpg" height="" width="" align="top"/>
here i like to have something like :
<br/> <b> get(phrase[thumb2].language[get(language)].text) </b> the width is get(stagewidth) <br/>
it works!!!
</textformat></font></p>
</data>
<data name="thumb3">
<p align="middle"><font face="Verdana" size="11"><textformat leftmargin="" rightmargin="">
<img src="../thumbs_lanterna/lanterna1.jpg" height="" width="" align="top"/>
more text:
stage height is get(stageheight) <br/> <b> get(phrase[thumb3].language[get(language)].text) </b> <br/>
it still works!!!
</textformat></font></p>
</data>
<data name="thumb4">
<p align="middle"><font face="Verdana" size="11"><textformat leftmargin="" rightmargin="">
<img src="../thumbs_lanterna/lanterna1.jpg" height="" width="" align="top"/>
and still more text:
<br/><b> get(phrase[thumb4].language[get(language)].text) </b><br/>
yeah!
</textformat></font></p>
</data>
<plugin name="thumb1"
x="30" y="30"
html="data:thumb1"
style="thumbstyle"
/>
<plugin name="thumb2"
x="270" y="30"
html="data:thumb2"
style="thumbstyle"
/>
<plugin name="thumb3"
x="510" y="30"
html="data:thumb3"
style="thumbstyle"
/>
<plugin name="thumb4"
x="750" y="30"
html="data:thumb4"
style="thumbstyle"
/>
<style name="thumbstyle"
url="%SWFPATH%/plugins/textfield.swf"
keep="true"
visible="true" enabled="true" handcursor="true" capture="true" children="true"
zorder="110"
width="220" height="150"
alpha="1.00" blendmode="normal"
smoothing="true"
origin="leftbottom" edge=""
onhover="showtext(get(phrase[get(name)].language[get(language)].text));"
onloaded="txtadd(update,'update_thumb(',get(name),');');call(update);"
background="true"
backgroundcolor="0xFFFFFF"
blur="0"
bordercolor="0x000000"
borderwidth="2"
css="data:defaultcss"
roundedge="8"
selectable="false"
shadow="3"
/>
<plugin name="combobox"
url="%SWFPATH%/plugins/combobox.swf"
align="lefttop"
x="10"
y="10"
keep="true"
onloaded="action(setupitems);"
/>
<action name="setupitems">
removeall();
additem(dutch, set(language,dutch);update_plugins(););
additem(german, set(language,german);update_plugins(););
additem(english, set(language,english);update_plugins(););
additem(french, set(language,french);update_plugins(););
additem(spanish, set(language,spanish);update_plugins(););
additem(japanese, set(language,japanese);update_plugins(););
additem(pig latin, set(language,pig_latin);update_plugins(););
</action>
<action name="update_plugins">
foreach(plugin,action[%0].i,
if (plugin[get(action[%0].i)].update !== null,
call(plugin[get(action[%0].i)].update);
);
);
</action>
<!-- _foreach_action
private function to execute foreach loop body action -->
<action name="_foreach_action">
trace("Error in foreach loop: push/pop stack corrupted"); <!-- this line should never execute -->
</action>
<!-- foreach <objectid> <index.str> <body.str>
foreach loop function which iterates the action across each of the objects-->
<action name="foreach"> <!--objectid.str,index.str,body.str-->
set(%2,0);
push(action[_foreach_action].content);
set(action[_foreach_action].content,"if(%2 LT %1.count,%3;inc(%2);_foreach_action(););");
_foreach_action();
pop(action[_foreach_action].content);
</action>
</krpano>
Display More
Hope this helps!
steve