dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: pause the actionscript from execution for 5 seconds

Hybrid View

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    221

    pause the actionscript from execution for 5 seconds

    i have a one frame movie with all the actionscript cluttered...

    I want the actionscript to pause or delay for a few seconds from executing and then continue on its own... how can this happen?

    Thanks!
    Cheers,
    Bananaz
    Attachments are dangerous; Even in emails !!!

  2. #2
    Esquire Frank DeRosa's Avatar
    Join Date
    Dec 2002
    Location
    the Matrix
    Posts
    144
    Is it critical that your script all execute in one frame? If not, put 5 seconds worth of frames in between the scripts that need to be separated.

    Frank

  3. #3
    Senior Member
    Join Date
    May 2001
    Posts
    221
    Below is my code... all of it is in one(first) frame
    is there no way we can say..... delay(500) as we do in other programming languages?

    --------------------------------------




    fscommand("fullscreen", "true");
    fscommand("showmenu", "false");
    fscommand("allowscale", "true");
    slides_xml = new XML();
    slides_xml.onLoad = startSlideShow;
    slides_xml.load("sds.xml");
    slides_xml.ignoreWhite = true;
    targetClip._alpha = 0;
    //
    // Show the first slide and intialize variables
    function startSlideShow(success) {
    if (success == true) {
    rootNode = slides_xml.firstChild;
    totalSlides = rootNode.childNodes.length;
    firstSlideNode = rootNode.firstChild;
    currentSlideNode = firstSlideNode;
    currentIndex = 1;
    updateSlide(firstSlideNode);
    }
    }
    //
    // Updates the current slide with new image and text
    function updateSlide(newSlideNode) {
    imagePath = newSlideNode.attributes.jpegURL;
    // added this to create a temp mc that can be removed
    // _root.createEmptyMovieClip("temp_mc", -500);
    // added this to get the alpha fading to work properly
    // _root.temp_mc.onEnterFrame = function()
    onEnterFrame = function () {
    if (targetClip._alpha>10 && fadeOut){
    targetClip._alpha -= 10;}
    if (targetClip._alpha<10) {
    targetClip.mohak.loadMovie(imagePath);
    targetClip2.mohak.loadMovie(imagePath);
    fadeOut = false;
    fadeIn = true;}
    if (targetClip._alpha<100 && fadeIn && !fadeOut)
    {
    targetClip._alpha += 10;}
    else {fadeIn = false;}
    if (input>30){
    input = 30;}
    slideText = newSlideNode.firstChild.nodeValue;
    styleId = newSlideNode.attributes.ID;

    if (currentIndex<30 && !fadeIn && !fadeOut) {
    fadeOut = true;
    nextSlideNode = currentSlideNode.nextSibling;
    updateSlide(nextSlideNode);
    currentSlideNode = nextSlideNode;
    }};
    }
    //
    // Event handler for 'Next slide' button
    next_btn.onRelease = function() {
    nextSlideNode = currentSlideNode.nextSibling;
    if (nextSlideNode == null) {
    break;
    } else {
    updateSlide(nextSlideNode);
    currentSlideNode = nextSlideNode;
    if (currentIndex<30 && !fadeIn && !fadeOut) {
    fadeOut = true;
    currentIndex++;
    input = currentIndex;
    }
    }
    };
    //
    // Event handler for 'Previous slide' button
    back_btn.onRelease = function() {
    previousSlideNode = currentSlideNode.previousSibling;
    if (previousSlideNode == null) {
    break;
    } else {
    currentSlideNode = previousSlideNode;
    updateSlide(previousSlideNode);
    if (currentIndex>1 && !fadeIn && !fadeOut) {
    fadeOut = true;
    currentIndex--;
    input = currentIndex;
    }
    }
    };
    Cheers,
    Bananaz
    Attachments are dangerous; Even in emails !!!

  4. #4
    Esquire Frank DeRosa's Avatar
    Join Date
    Dec 2002
    Location
    the Matrix
    Posts
    144
    I suppose you could write up a while loop like this (pseudocode):

    [FONT = courier new]startTime = currentTime();
    delayLength = 5000;

    While((startTime - currentTime) > delayLenght){
    //do nothing
    }[/FONT]

    It's an old fashioned delay loop. It probably isn't precise, but it wouldn't be far from 5 sec.

    Frank

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