1 Reply Latest reply on Apr 5, 2011 10:16 PM by Flex harUI

    Image URL with embed image fallback

    Steve Springett

      I have a very simple requirement which I cannot figure out how to implement.

       

      I'm parsing an XML file from a server. If the value of 'hasArtwork' is true, then I want to load the external image. If the value is false, I want to use an embedded image. I also want this logic hidden so that it's reusable.

       

      Basically, it's like any media player you've seen. If the title has artwork then display it, if not, then display a 'no artwork available' image.

       

      <mx:Image source="{ mediaController.media.artwork.image }" width="100%" height="100%"/>

       

      The controller has already populated the media object. Inside the media object, there's a MediaArtwork object with a getter and setter for 'image'.

       

      public function get image():Class

      {

           if (_hasArtwork)

                return _image;

           else

                return defaultImage;

      }

       

      I'm successfully returning the defaultImage. However, how do I get the external _image to return from this method? Using Flex 3.