www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] Timing Delema

  1. #1
    Join Date
    Jul 2010
    Posts
    71

    resolved [RESOLVED] Timing Delema

    I have a script that fades a picture in and i want it to disappear when a certain function runs.. i tried using an if/else (when i == 2) and defining the variable in the first function but return; stops the code, any other ideas?

  2. #2
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Hi,

    Could you please post the code or (preferably) a link? It's a little hard to help out when there's nothing to work with. ;-)
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  3. #3
    Join Date
    Jul 2010
    Posts
    71
    i is defined here in a loop (function that calls the first function at the end for infinite loop) and note this is only one of many identical functions that only change the opacity.
    Code:
    function pic1h(){
    i = 2;
    // return i; only reason i dont put it in is because it stops timeout from calling the next function
    document.myimg.style.opacity = 1/10;
    document.myimg.style.filter = 'alpha(opacity=' + 1*10 + ')';
    setTimeout('pic1i ()', 100);
    }
    And here is the function that is calling i to tell the picture to fade out.
    The beggining of this code is executed onclick
    Code:
    function box1end(i){
    if (i == 2)
      {
    document.myimg4.style.opacity = 0/10;
    document.myimg4.style.filter = 'alpha(opacity=' + 0*10 + ')';
    document.getElementById('gal4').style.opacity = 0/10;
    document.getElementById('gal4').style.filter = 'alpha(opacity=' + 0*10 + ')';
    document.getElementById('gal5').style.opacity = 0/10;
    document.getElementById('gal5').style.filter = 'alpha(opacity=' + 0*10 + ')';
    document.getElementById('gal6').style.opacity = 0/10;
    document.getElementById('gal6').style.filter = 'alpha(opacity=' + 0*10 + ')';
      }
    else
      {
      document.myimg4.style.opacity = 10/10;
      document.myimg4.style.filter = 'alpha(opacity=' + 10*10 + ')';
      setTimeout('box1end()', 100);
      }
    }

  4. #4
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    I might be missing something, but... why not just move your return statement to the end of the function?

    Code:
    function pic1h(){
    i = 2;
    document.myimg.style.opacity = 1/10;
    document.myimg.style.filter = 'alpha(opacity=' + 1*10 + ')';
    setTimeout('pic1i ()', 100);
     return i;
    }
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  5. #5
    Join Date
    Jul 2010
    Posts
    71
    i didnt think you could execute anything after settimeout, thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles