0 Replies Latest reply on Dec 10, 2009 3:55 PM by mikki65

    xml slideshow with random PICTS and mx.transitions

    mikki65

      Hi All,
      I am building a web banner with a slideshow with random picts via xml,
      but i want to use a iris transition to fade in while getting the pict, and fade out with the iris transition, the last action works but when getting i cannot get the transition to work below is a piece of the code:

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

      pauseTime = 2000;

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

      function loadImages(loaded) {
          if (loaded) {
              xmlFirstChild = this.firstChild;
              imageFileName = [];
              totalImages = xmlFirstChild.childNodes[0].childNodes.length;
              for (i=0; i<totalImages; i++) {
                  imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
              }
              randomImage();
          }
      }
      function randomImage() {
          if (loaded == filesize) {
              var ran = Math.round(Math.random() * (totalImages - 1));
              picture_mc._alpha = 0;  // Start image clip as invisible
              picture_mc.loadMovie(imageFileName[ran], 1);  //Load random image from xml
              var pictureTweenIn:Tween = new Tween(picture_mc, "_alpha", Normal.easeIn, 0, 100, 4, true); //WORKS!
              mx.transitions.TransitionManager.start(picture_mc, {type:mx.transitions.Iris, direction:mx.transitions.Transition.OUT, duration:3, easing:mx.transitions.easing.Regular.easeInOut});   // DOES NOT WORK?   
              pictureTweenIn.onMotionFinished = function () { // When done fading
              _root.pause();  // Start pause() function
              }
          }
      }
      function pause() {
          myInterval = setInterval(pause_slideshow, pauseTime);
          function pause_slideshow() {
              clearInterval(myInterval);
              var pictureTweenOut:Tween = new Tween (picture_mc,"_alpha",Normal.easeOut,100,0,5,true);
      //WORKS!
              mx.transitions.TransitionManager.start(picture_mc, {type:mx.transitions.Iris, direction:mx.transitions.Transition.OUT, duration:3, easing:mx.transitions.easing.Regular.easeInOut});  //WORKS!     
              pictureTweenOut.onMotionFinished = function() {
                  _root.randomImage();  // Call next randomImage()
              };
          }
      }


      If anyone can help me out this would be great!

       

      Mikki65