5 Replies Latest reply on Nov 14, 2010 8:42 AM by Ned Murphy

    images random

    loubras

      Hello,

       

      I have used a code to produce random of images in a flash movie:

       

      var ldr:Loader=new Loader();
      addChild(ldr);
      ldr.load(new URLRequest("ima00" + (Math.ceil(Math.random()*5)) + ".jpg"));

       

      With that code, besides the random of images each time you acess the website (that is ok!), it keep changing the images while you still with the swf open. We would like to change it, making it to load a different image each time we get in the web site, but making the images to keep still, not changing while the film is open.

       

      Is that posible?

       

      Thanks a lot!

        • 1. Re: images random
          Ned Murphy Adobe Community Professional & MVP

          That is AS3 code, so you should post in the AS3 forum.  The code you show will not continuously change images.  There is something else that will make that happen, either some timer that activates periodically, or maybe your timeline loops back to that frame.  If it is the latter, then you need to have a stop(); command to keep the timeline from looping.

          1 person found this helpful
          • 2. Re: images random
            loubras Level 1

            Thanks a lot Ned

             

            I did the change and now it does not load other images in sequence, however the

            swf is not working online. It was correctly exported on AS3 and the website is

            all AS3. All the images and the swf are online, inside the same folder.. etc.

             

            The random is a background image, essential to make the design work out. Do you

            know the reason this is not working online, only off line?

             

            The code i´m using in one frame movie is this one:

             

            var ldr:Loader=new Loader();

            addChild(ldr);

            ldr.load(new URLRequest("ima00" + (Math.ceil(Math.random()*5)) + ".jpg"));

            stop();

             

            Thanks a lot

            • 3. Re: images random
              Ned Murphy Adobe Community Professional & MVP

              If it works locally and not online, the problem is usually the location of the files.  If the swf and images are in the same folder, but the html page is in a different folder, then you need to alter the targeting within the swf as if the swf is in the same folder as the html file.  Even though the swf is in the same folder as the images, when it is loaded into the html page, that is its new relative home... something to the tune of...

               

              ldr.load(new URLRequest("FOLDERNAME/ima00" + (Math.ceil(Math.random()*5)) + ".jpg"));

              • 4. Re: images random
                loubras Level 1

                Thanks a lot Ned!

                 

                It was that, index was outside of the main folder. I just copied the files, and

                now it's working perfect.

                 

                Best Regards!

                • 5. Re: images random
                  Ned Murphy Adobe Community Professional & MVP

                  You're welcome