4 Replies Latest reply on Aug 10, 2008 4:32 PM by

    Add IconButton dynamically

      Hi,<br /><br />What I am trying to achieve is a display a list of folders in a window. Each of these folders contain PNG files.<br /><br />I want to display these png files as icons in a panel in the window. While it displays the first file in the loop it does not display the rest. Any ideas on what I am doing wrong in the following code snippet?<br /><br />w.DropDownList.onChange= function()<br />{ <br />     iconFolder=Folder("/C/XYZ/"+this.selection.text);<br />     iconFileList= iconFolder.getFiles("*.png");<br />     x=10;<br />     y=10;<br />     for (var h=0; h<iconFileList.length; h++)<br />     {<br />          w.iconPnl.add ("iconbutton", [x,y,70,70], iconFileList[h]);<br />          x=x+71;<br />     }<br />     <br />}
        • 1. Re: Add IconButton dynamically
          Anything?? Anybody???
          • 2. Re: Add IconButton dynamically
            I was setting the wrong parameters for Geometric Bounds which was why this wasn't working. I've got that fixed since.<br /><br />However, I am having a problem using onClick to do different tasks for each of the buttons.<br /><br />I'm sure I'm doing something silly again but for the life of me, I cannot figure out what.<br /><br />Here is a section of my code:<br />for (var h=0; h<iconFileList.length; h++)<br />{<br />  this["upBtn"+h]=this.selection.panel.add ("iconbutton", [x1,y1,x2,y2], iconFileList[h])<br />  row=row+1<br />  x1=x1+62;<br />  x2=x2+62;<br />  if (row==4)<br />  {<br />    row=0<br />    x1=10<br />    y1=y1+62;<br />    x2=70<br />    y2=y2+62;<br />  }<br />}<br />} <br />"upBtn"+h.onClick=function(h)<br />{<br />  alert("Here")<br />}
            • 3. Re: Add IconButton dynamically
              Oops Sorry about the way this code displayed: Here it is::<br /><br />iconFolder=Folder("/C/XYZ/"+this.selection.text);<br />iconFileList= iconFolder.getFiles("*.png");<br />for (var h=0; h<iconFileList.length; h++)<br />{<br />          this["upBtn"+h]=this.selection.panel.add ("iconbutton", [x1,y1,x2,y2], iconFileList[h])<br />          row=row+1<br />          x1=x1+62;<br />          x2=x2+62;<br />          if (row==4)<br />          {<br />               row=0<br />               x1=10<br />               y1=y1+62;<br />               x2=70<br />               y2=y2+62;<br />          }<br />     }<br /><br />   <br />} <br /><br />"upBtn"+h.onClick=function(h){<br />     alert("Here")<br />     }
              • 4. Re: Add IconButton dynamically

                Adobe pls wake up and add tabs to allow us to post code like the other forums out there.

                In saying that I have however got more help from the adobe forum than I have from the other forums out there! And that matters more.