3 Replies Latest reply on May 10, 2016 10:06 PM by tpk1982

    Making a preview of an image switch?

    cbishop01 Level 2

      I'm wanting the Pic to change depending on what Radio button i have selected.  Is this possible with Indesign scripting?

       

      // How can i make PreV1 activate the below Radio buttons?  Maybe gray out the Buttons when not the Check box is not checked.  
             
                  var PreV1= w.tabs[2].add ('checkbox {text: "To Preview Changes"}');  
                  var Pan1=w.tabs[2].add ('panel {text: "", preferredSize: [-1, 200],orientation: "column",alignChildren: ["left","top"]}');  
                  
      // Is there a way to make each radio button display a Different Pictrue?          
             
                          Pan1.add('radioButton {text: "B1.   Enter Here1"}');  
                          Pan1.add('radioButton {text: "B2.   Enter Here2"}');  
                          Pan1.add('radioButton {text: "B3.   Enter Here3"}');  
                          Pan1.add('radioButton {text: "B4.   Enter Here4"}');  
                          Pan1.add('radioButton {text: "B1.   Enter Here5"}');  
                          Pan1.add('radioButton {text: "B2.   Enter Here6"}');  
                          Pan1.add('radioButton {text: "B3.   Enter Here7"}');  
                          Pan1.add('radioButton {text: "B4.   Enter Here8"}');  
              
             
                     Image.prototype.onDraw =function()  
                      {  
                      if(!this.image )return;  
                      var WH =this.size,wh   =this.image.size,k   = Math.min(WH[0]/wh[0], WH[1]/wh[1]), xy;  
                        wh   =[k*wh[0],k*wh[1]];  
                        xy   =[(WH[0]-wh[0])/2, (WH[1]-wh[1])/2 ];  
                      this.graphics.drawImage(this.image,xy[0],xy[1],wh[0],wh[1]);  
                         WH   = wh = xy =null;  
                      }  
                     flower=w.tabs[2].add ("image", undefined, File ("~/\Desktop/\xxx.jpg"));  
                     flower.size =[300,300];  
                
              for(  
              var i = 0;  
               i < w.tabs.length;  
               i++){  
              w.tabs[i].orientation ='column';  
              w.tabs[i].alignChildren ='fill';  
              w.tabs[i].alignment =['fill','fill'];  
              w.tabs[i].visible =false;  
              }  
              w.stubs.onChange  = showTab;  
              function  
               showTab ()  
              {  
              if(w.stubs.selection !==null){for(var i = w.tabs.length-1; i >= 0;  
               i--)  
               {      
                   w.tabs[i].visible =false;  
              }  
                       w.tabs[w.stubs.selection.index].visible =true;  
              }  
              }  
                w.onShow  =function()  
              {  
              w.stubs.selection  = 1;  
              showTab;  
              }  
             
             
          myResult = w.show();   
      
      
        • 1. Re: Making a preview of an image switch?
          cbishop01 Level 2

          am i on the right path?  I turned off the lower radio buttons to give me more room to play with.

          
            radioButton = Pan1.add ('radioButton {text: "Pic1"}')  
                          Image.prototype.onDraw =function(){  
                          if(!this.image )return;  
                          var WH =this.size,wh   =this.image.size,k   = Math.min(WH[0]/wh[0], WH[1]/wh[1]), xy;  
                            wh   =[k*wh[0],k*wh[1]];  
                            xy   =[(WH[0]-wh[0])/2, (WH[1]-wh[1])/2 ];  
                          this.graphics.drawImage(this.image,xy[0],xy[1],wh[0],wh[1]);  
                             WH   = wh = xy =null;}  flower=w.tabs[2].add ("image", undefined, File ("~/\Desktop/\xxx.jpg")); 
          
          
          
          
                             flower.size =[300,300];  
          /* 
                              Pan1.add('radioButton {text: "B2.   Enter Here2"}'); 
                              Pan1.add('radioButton {text: "B3.   Enter Here3"}'); 
                              Pan1.add('radioButton {text: "B4.   Enter Here4"}'); 
                              Pan1.add('radioButton {text: "B1.   Enter Here5"}'); 
                              Pan1.add('radioButton {text: "B2.   Enter Here6"}'); 
                              Pan1.add('radioButton {text: "B3.   Enter Here7"}'); 
                              Pan1.add('radioButton {text: "B4.   Enter Here8"}'); 
          */          
          
          
          • 2. Re: Making a preview of an image switch?
            cbishop01 Level 2

            I should mention that this preview will be on the UI of my script.