A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Displaying an image for a set time using actionscript

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    171

    Displaying an image for a set time using actionscript

    Hello all,
    If i have the following code:
    Code:
    next_btn.onRelease = function() {
        nextImageNode = currentImageNode.nextSibling;
        if (nextImageNode == null) {
            break;
        } else {
            currentIndex++;
            updateImage(nextImageNode);
            currentImageNode = nextImageNode;
        }
    };
    this checks to see if "nextImageNode" has a "nextSibling" (an image) when the "next_btn" is clicked.
    If null then it stops else it goes to the next image by updating to nextImageNode. It then gives "currentImageNode" the value of the current image.

    At least I think that's correct?

    Knowing all that what i want to do is add another button (aut_start) that when clicked displays the current image (currentImageNode) for 20 seconds then goes to the next image (nextImageNode) and displays that for 20 seconds and so on till it gets to the end of the image slide show.

    Can anyone give me some advice on how to achieve this?

    Cheers,
    Suzy

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    You could most probably use setInterval to create a 20 seconds pause between each picture being displayed.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    171
    Thanks for the reply oldnewbie.

    Neally there...I think

    This is what I have so far:
    Code:
    auto_start.onRelease = function() {
        nextImageNode = currentImageNode.nextSibling;
        if (nextImageNode == null) {
            break;
        } else {
            displayTime = 20;
            countDown = function (message) { displayTime--;if (displayTime == 0) {clearInterval(timer);currentIndex++;updateImage(nextImageNode);currentImageNode = nextImageNode;}};
            timer = setInterval(countDown, 1000);
        }
    };
    This works fine, except it only allows me to do it once.
    What function or code do i need to add to the above code to make it loop through the above process until it gets to the end (nextImageNode == null)?

    Regards,
    Suzy

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Try this:
    auto_start.onRelease = function() {
    nextImageNode = currentImageNode.nextSibling;
    if (nextImageNode != null) {
    displayTime = 20;
    countDown = function (message) {
    displayTime--;
    if (displayTime == 0) {

    currentIndex++;
    updateImage(n
    extImageNode);currentImageNode = nextImageNode;
    if (nextImageNode == null) {
    break;
    clearInterval(timer);
    }
    }
    };
    timer = setInterval(countDown, 1000);
    }
    };
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Wow! We're on a roll this morning! Aren't we!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center