3 Replies Latest reply on Aug 7, 2006 5:03 PM by CogDev

    Swap Images

      Is there a code I can use to swap images on my home page.

      Example: I have 6 images I want to rotate on my home page and each with a fade in-out transisition.

      In stead of laying out; fade in, 50 frames, fade out, next image...is there a script I can use?

      Using so many frames makes for a bigger file.

      Please help.

      Thank you!


        • 1. Re: Swap Images
          What you need is an array for the URL's and then code that tells the movie what to load and when. I'm writing this off the top of my head, so you may need to mess with it to make it work:

          var fileList = [pic1,pic2, pic3]
          var fileCount:Number = 3;
          var thisObj = this;
          var frameCount = 0;
          var fileIndex = 0;
          var holder:MovieClip = new MovieClip();
          for(fileIndex = 0; fileIndex < fileCount; fileIndex ++){
          holder.fileList[fileIndex]._alpha = 0;
          fileIndex = 0;
          var fadeFrames = 50; // how many frames to wait before fading
          _root.onEnterframe = function(){
          var fadeSpeed = 5;
          if(thisObj.holder.fileList[fileIndex+1]._alpha == 100){
          thisObj.fileIndex += 1;
          /** OPTIONAL
          // if you want the whole thing to repeat, then uncomment this section
          if(fileIndex == fileCount+1)fileIndex = 0;
          thisObj.frameCount = 0;
          if (thisObj.frameCount > thisObj.fadeFrames){
          thisObj.holder.fileList[fileIndex]._alpha -=fadeSpeed;
          thisObj.holder.fileList[fileIndex +1]._alpha += fadeSpeed;
          if(thisObj.holder.fileList[fileIndex]_alpha < 100) thisObj.holder.fileList[fileIndex]._alpha += fadeSpeed;

          • 2. Re: Swap Images
            kelly_@_herco Level 1
            Ok, but I'm not sure what you mean by an array of URLs.

            Thank you.

            • 3. Swap Images
              CogDev Level 1
              What I mean is a list of links to the image files.

              to make this work, you need to replace "pic1,pic2" etc with the names of your files (in quotes!) , and then change the variable fileCount to indicate how many there are.