1 Reply Latest reply on Jun 15, 2011 6:45 PM by dustout

    Symbol script to change image


      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

        • 1. Re: Symbol script to change image
          dustout Level 1

          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.






          .jsf file









          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;