1 Reply Latest reply on Oct 2, 2007 11:14 PM by balamurugan@flipdesign.in

    Display random image from XML file with associated link

    Rectallinear
      Here's the XML file I'm starting with:

      <?xml version="1.0"?>
      <images>
      <pic> <image>image1.jpg</image> <link> http://www.nbc.com</link> </pic>
      <pic> <image>image2.jpg</image> <link> http://www.abc.com</link> </pic>
      <pic> <image>image3.jpg</image> <link> http://www.cbs.com</link> </pic>
      </images>

      I need some help figuring out the Actionscript to display a random image from this list in a movie clip in such a way that the user will be able to click on the image (for instance, image 3) and be taken to the associated URL (in this case, www.cbs.com).

      Any help would be greatly appreciated.
        • 1. Re: Display random image from XML file with associated link
          balamurugan@flipdesign.in
          Hi Rectallinear
          i can give you the idea how it can be done...
          option 1:
          in the images tag specify a attribute that will contain the total number of images so that you can read that value and take a random of that number and load the image and the link according to that. in runtime
          option2:
          you can store all the values in a 2 dimension array and find the length of the array and take random of that array length and according to that you can link the button. In this case you can store the image and corresponding path(Url) for that
          or else you can also count while you are reading from the XML file...

          To display a image you can use a component called Loader and set the path of the image dynamically using the property .contentPath in action script...