Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question fade in images - random image slideshow

    Hi
    I was looking for random slideshow three weeks and finaly found, here.
    I have tried it and works perfectly
    But I want each image to fade in top of another, with no pause. Is that possible?
    What should I change in the code, and where?
    Thanks


    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,1,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds
    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,1,true); // After pause, start fade out
    pictureTweenOut.onMotionFinished = function () { // Once faded out
    _root.randomImage(); // Call next randomImage()
    }
    }
    }

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    pauseTime = 2000;

    Put in a lower number

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the quick answer
    But what I mean is when the fade finishes there is white backround for half a second, and than starts the other image.
    I want the image to fade in top of the image

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    This is the code I produced, and here should be a good variation for your needs. I haven't tested it, but it simply avoids the pause function and just reloads the randomImage function, which loads a new image on top. It probably needs some adjustments so that the new image doesn't destroy the old image when loaded.

    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,1,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds
    pictureTweenIn.onMotionFinished = function () { // When done fading
    _root.randomImage(); // Start pause() function
    }
    }
    }
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •