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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Marseille, France
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question inserting a pause into a function

    Hello!

    Can anyone help me, how to insert a pause into my scrolling script (or into any script)?
    The execution of the script should stop for a few seconds, then continue.
    This migt complicate it even more: In the scroller script, I have integrated an if-then function, and if a particular object (an array) exists the scroller script begins to rotate images as well. The pause should only occur, if the if-then function returns true, so that the viewer has enough time to view the photos.

    Thank you all, a million times!

    Fuli42
    //-->Fuli42

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    gimme a link to ur site and i'll see what i can do
    Computers are simple for the complex mind, yet complex for the simple mind

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Marseille, France
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the scroller script, but it is only a part of the whole, and some lines are in Hungarian, sorry! I really don't want to waste your time, going through my 300+ lines of code. I've copied only the part that does the scrolling.

    It is quite flexible, you can set direction, speed, stop it, set the layer to be scrolled.

    One way to slow it would be to set in scrollTimer instead of 1, a higher number. But then, the movement would be too jagged. The best solution would be, if the just after the testing for the existance of image links on the layer, you could insert a pause.

    If you need the whole code:

    http://ortofamily.dns2go.com/huglass...oba/full2.html

    and http://ortofamily.dns2go.com/huglass...oba/minden3.js

    Thank you all!!!!

    // scrolling script starts -->

    // Translation: ir/rany=dir, seb/sebesseg=speed, loop=loop, reteg = layer to be moved

    k = -1;
    function gorog(ir, seb, loop, reteg) {
    loop = true;
    irany = "fel";
    sebesseg = 1;
    scrolltimer = null;
    ret = reteg;
    if (document.layers) {
    var page = eval(document.layers[ret]);
    }
    else {
    if (document.getElementById) {
    var page= eval("document.getElementById(ret).style");
    }
    else {
    if (document.all) {
    var page = eval(document.all.ret.style);
    }
    }
    }
    irany = ir;
    sebesseg = parseInt(seb);
    var y_pos = parseInt(page.top);
    var x_pos = parseInt(page.left);
    // if there are links to images on the layer, they have to be rotated
    var tombnev = reteg + "kepek";
    //checks, if there are image links on the layer
    if ((tombnev == "kapcsol98kepek") || (tombnev == "madridkepek") || (tombnev == "szimp99kepek") || (tombnev == "szimpoz97kepek") || (tombnev == "kiallit96kepek") || (tombnev == "usakepek")) {
    //
    //If only I could insert a pause here...
    //
    var selector = (eval(y_pos)-140)/40*-1;
    var egesz = Math.floor(selector) + 1;
    var egeszelotti = eval(egesz) -1;
    var egeszutani = eval(egesz) +1;
    tombnevreal = eval(tombnev);
    tombhosszreal = eval(tombnevreal.length);
    var j = eval(egesz) *5;
    if ((tombhosszreal -6 < j ) && (irany = "le")){
    // loop = false, the scroll changesdirection, it goes up now (irany = direction, fel = up)
    irany = "fel";
    }
    if ((k != j) && (tombhosszreal -6 > j )){
    var tombnev = reteg + "kepek";
    tombnevarr = eval(tombnev);
    var adott = reteg +"belso" + egesz;
    var adottelotti = reteg +"belso" + egeszelotti;
    var adottutani = reteg +"belso" + egeszutani;
    // this part is just for highlighting the selected link
    WM_swapLayerBgcolor(adott,'#ccffff solid 1px','red');
    // the kepreszab function displays the images, on another layer
    kepreszab(tombnevarr[j],tombnevarr[j+1],tombnevarr[j+2],tombnevarr[j+3]);
    WM_swapLayerBgcolor(adottelotti,'0px','');
    WM_swapLayerBgcolor(adottutani,'0px','');
    }
    k=j;}
    // if there are no images to rotate, the scroll continues here
    if (loop == true) {
    if (irany == "le") {
    page.top = (y_pos - (sebesseg));
    } else {
    if (irany == "fel" && y_pos < 130) {
    page.top = (y_pos + (sebesseg));
    } else {
    if (irany == "bal" && x_pos > -800) {
    page.left = (x_pos - (sebesseg));
    } else {
    if (irany == "jobb" && x_pos < 260) {
    page.left = (x_pos + (sebesseg));
    } else {
    if (irany == "top") {
    page.top = 10;
    }
    }
    }
    }
    }
    scrolltimer = setTimeout("gorog(irany,sebesseg,true,ret)", 1);
    }
    }
    function stopgorog() {
    loop = false;
    clearTimeout(scrolltimer);
    }
    // scrolling script ends -->
    Thanks
    //-->Fuli42

  • #4
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Marseille, France
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just one more note:

    Go into 2000 mmm.transglass.hu Madrid -> then "Mutargyak", on the page, to see where I would like to insert the pause.

    (Works on NS4+, IE4+)
    //-->Fuli42

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The simplest solution would be to split your function into two seperate functions, and then call the second with setTimeout().

    If there are any local variables in the first function that you would need in the second, you can pass them as arguments.

    Hope that helps.

  • #6
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Marseille, France
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THanks!
    i dunno, it might only stop the loading of images, but not the scrolling itself. The scroller invokes the image changes, on another layer.

    But, the scroller can e stopped by calling the stopgorog() function.
    So I would insert in a separate function a stopgorog() then a
    setTimeout{(stargorog()), 5000}

    Normally startgorog (the scrolling script) takes 5 parameters, if I don't give it any parameters, it should continue with the same ones, that it used before it was stopped. If not I will have an error...
    Will try this, tomorrow
    //-->Fuli42

  • #7
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Marseille, France
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solution!!

    I've found the solution:
    Just after the image swap, I change the loop to false, which stops the scroll.
    THen with a setTimeout, I restart the scroll.
    Huh!
    //-->Fuli42

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make sure you use clearTimeout() when needed!

  • #9
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Marseille, France
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you.
    Yes indeed sometimes, two or more calls to the same function resulted in some strange "effects"...
    //-->Fuli42


  •  

    Posting Permissions

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