2 Replies Latest reply on Jun 2, 2008 10:01 PM by smokingguns

    Neophite Question

      hey all,
      Im trying out the example given in 'Developing on Adobe AIR with Aptana Studio' article. In this example the author discusses a local file system browser. I replicated the example in Aptana Studio without any problems. Then I thought of displaying file icons based on the file extension. Here is the piece of code thats troubling me:

      This is the original code:

      content += "<td class='" + tdClass + "'>" + children[x].name + "</td>";

      After modification:


      content += "<td class='" + tdClass + "'><img src=icons/"+children[x].extension+".png/>"+children[x].name + "</td>";

      I have all the respective file icons in the icons folder(doc.png,xls.png,pdf.png etc). So the idea was to display the file icon along with the file name, on the fly.(Based on the file extension, create the image source) But this doesnt seem to work at all. Can anybody point me in the right direction.
        • 1. Re: Neophite Question
          anirudhs Level 2

          I don't if the quotes are missing due to a problem with the forums, but the value for src attribute of an img tag should be enclosed in quotes.

          Try this:


          content += "<td class='" + tdClass + "'>" + "<img src=\"icons/"+ children[x].extension + ".png\" />" + children[x].name + "</td>";
          • 2. Re: Neophite Question
            smokingguns Level 1
            Thanx for the reply. But for some reason the images appear intermittently. I dont know if its a DOM problem(Im not that good at javascript).I also tried using CSS to solve the problem. This is what I did:


            .doc {
            background-image: url(icons/doc.png);
            background-repeat: no-repeat;


            .pdf {
            background-image: url(icons/pdf.png);
            background-repeat: no-repeat;


            And tried to make the images appear on the fly (based on their file extensions) like this:


            fltype=children[x].extension //if extension is doc, the class of td is set to doc
            content += "<td class='" + fltype+ "'></td>";

            The images do appear, but the behavior is intermittent. They appear the fiirst time I select a folder for browsing and if I select a subfolder to view the files, the icons disappear. My CSS seems to be correct, but still this problem.
            Can anybody tell me what am i doing wrong??