1 Reply Latest reply on Jul 1, 2008 7:52 AM by vanroojdotcom

    Fade in – images

    vanroojdotcom
      Hi there – I need help with this problem. I'm not a Flash person but | have collated various bits of tutorials from different forums and have 90% what I need – but it's just not there. I don't want anything fancy – just 780x250 banner that rotates gently through a series of images pulled from an XML file – no rollovers or music just the banner subtly changing this image every 10 seconds or so. Right, here is the code I've gleaned...

      pauseTime = 3000;

      xmlImages = new XML();
      xmlImages.ignoreWhite = true;
      xmlImages.onLoad = loadImages;
      xmlImages.load("images.xml");

      import mx.transitions.Tween;
      import mx.transitions.easing.*;

      function loadImages(loaded) {
      if (loaded) {
      xmlFirstChild = this.firstChild;
      imageFileName = [];
      totalImages = xmlFirstChild.childNodes[0].childNodes.length;
      for (i=0; i<totalImages; i++) {
      imageFileName = xmlFirstChild.childNodes[0].childNodes.attributes.title;
      }
      randomImage();
      }
      }
      function randomImage() {
      if (loaded == filesize) {
      var ran = Math.round(Math.random() * (totalImages - 1));
      picture_mc.loadMovie(imageFileName[ran], 1);
      pause();
      }
      var myTween:Object = new Tween(picture_mc, "_alpha", Strong.easeInOut, 0, 100, 3, true);
      }
      function pause() {
      pauseInterval = setInterval(pause_slideshow, pauseTime);
      function pause_slideshow() {
      clearInterval(pauseInterval);
      randomImage();
      }
      }



      This works really well – the only problem is to fade the image OUT! So it fades in nicely, waits a few seconds and then it cuts to the black stage before fading the next image in.

      Now, changing this this line:
      var myTween:Object = new Tween(picture_mc, "_alpha", Strong.easeInOut, 0, 100, 3, true);
      to this:
      var myTween:Object = new Tween(picture_mc, "_alpha", easeInOut, 20, 100, 15, false);

      Makes it pretty close but it's more jumpy in the transition – I just want a nice, slow fade in – pause – fade out!



      Really apreaciate any help on this.
      Vanrooj