4 Replies Latest reply on Mar 26, 2009 1:48 PM by Handycam

    Problem testing for empty value

    Handycam Level 1
      I just made an XML-driven application where nodes have an optional image, which I would enter in an image node in the XML file, as in:

      <image>/images/myimage.jpg</image> or, if no image, <image></image>

      In the initial application, there were a few images and the rest were empty nodes. Worked fine, it seems.

      In my second release, this time the xml file calls for no images, all the image nodes are empty. So now I get a runtime error, "cannot load ''", which would seem it is trying to load an image file of an empty string.

      I have also tried setting the nodes that don't need an image to have a string value of "none" and then testing for that in the IF statement, same thing. I can only get this XML to load and the app to run if I comment out the IF block in the attached code.

      Any ideas?

        • 1. Re: Problem testing for empty value
          Gregory Lafrance Level 6
          This code seems to work. Maybe I am missing something in this contrived sample app.


          • 2. Re: Problem testing for empty value
            Garyl Woolworth Level 1
            The only part about your post that doesn't really make sense to me is that you said
            quote:

            So now I get a runtime error, "cannot load ''", which would seem it is trying to load an image file of an empty string.
            however any time I have ever loaded an image into Flex and passed it a string (quite a few times) I've never gotten a run time error just because it couldn't find a source, the application just showed either nothing or a broken image icon. I think there is something else tripping up the application, what is the full output of the error you get? Also, are you catching any errors on the image component itself like IOError, Security errors, etc...?
            • 3. Re: Problem testing for empty value
              Handycam Level 1
              Well, me too, that was just a guess.

              All I know for a fact is that when that IF block is in there, and my XML file has no values in ANY of its <image> nodes, I get an error.

              If I remove that block OR I use an XML wherein some <image> nodes have valid image paths, no error.
              • 4. Re: Problem testing for empty value
                Handycam Level 1
                Greg: Yes, my previous project had an xml file similar to your example app, where some items had images, and it too worked fine. I was very surprised when I used my app for this second project which was the same except its xml file had ONLY empty <image></image> tags. This struck me as very odd, since the logic I used (and you use) seemed to be correct. I am not sure why it threw that error this time. The xml file validates fine.