Would it be possbile to have have a symbol script that allows me to select which image out of 5 or 6 should be viewable, and have it in just one field as compared to toggling the visibility of 6 seperate image fields
Managed to figure out how to do this by adding a few functions to the symbols .jsf file. If anyone happens to have the same problem a working version of my symbol and the corresponding .jsf code can be found below.
Sample
.jsf file
/*
4
Book%20Title,textChars,Book%20Title,Title;
Book%20Publisher,textChars,Book%20Publisher,Publisher;
Highlight%20Box,visible,Is%20Selected,false;
Visible%20Image,fontsize,Selected%20Image,0;
*/
function shouldIBeVisible(myNumber)
{
var values = Widget.elem.customData["currentValues"];
if (values[3].value == myNumber )
return true;
return false;
}
function isSelected(status)
{
if (status)
return "#ff0066";
return "#dac4a5";
}
function setDefaultValues()
{
var values = new Array();
values.push({ name:"Book Title", type:"text", value:"Title" });
values.push({ name:"Book Publisher", type:"text", value:"Publisher" });
values.push({ name:"Is Selected", type:"boolean", value:"false" });
values.push({ name:"Selected Image", type:"number", value:"0" });
Widget.elem.customData["currentValues"] = values;
}
function applyCurrentValues()
{
var values = Widget.elem.customData["currentValues"];
Widget.GetObjectByName("Book Title").textChars = values[0].value;
Widget.GetObjectByName("Book Publisher").textChars = values[1].value;
Widget.GetObjectByName("Highlight Box").pathAttributes.brushColor = isSelected(values[2].value);
Widget.GetObjectByName("Image1").visible = shouldIBeVisible(1);
Widget.GetObjectByName("Image2").visible = shouldIBeVisible(2);
Widget.GetObjectByName("Image3").visible = shouldIBeVisible(3);
Widget.GetObjectByName("Image4").visible = shouldIBeVisible(4);
Widget.GetObjectByName("Visible Image").fontsize = values[3].value;
}
switch (Widget.opCode)
{
case 1: setDefaultValues(); break;
case 2: applyCurrentValues(); break;
}