Can't seem to figure out how to get the ".complete" to return true or false...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moltendorf
    New Member
    • Jul 2007
    • 65

    Can't seem to figure out how to get the ".complete" to return true or false...

    Okay... so I'm generating a custom Slideshow tool for my friend... and I never seem to get any replies from Webberdev, so here I am, posting on a completely new forum...

    Anyways, the code is here: http://moltx.name/index_code.php?f=....p&u=1183295841
    The page is here: http://help.moltx.name/sites/darkvir...&image=sample2


    I've turned off the images from showing... just in the functions "preloadIma ges" I can't seem to get document.preloa dProgressBar.co mplete or any of the other items with .complete at the end of them to return true or false... I've rearanged the code a ton, and still have gotten an error saying the code is null.
  • Logician
    New Member
    • Feb 2007
    • 210

    #2
    Originally posted by moltendorf
    I've turned off the images from showing... just in the functions "preloadIma ges" I can't seem to get document.preloa dProgressBar.co mplete or any of the other items with .complete at the end of them to return true or false... I've rearanged the code a ton, and still have gotten an error saying the code is null.
    Have you checked that document.getEle mentById is actually returning a reference to an image?

    Comment

    • moltendorf
      New Member
      • Jul 2007
      • 65

      #3
      (Can't believe that I got a response. =D)

      It is returning a result, but my problem relies with preloading -this- part of the function:
      Code:
      		else if(this.preloaderLoading)
      			{
      				var preloaderProgressBar;
      				this.preloaderProgressBar = new Image();
      				this.preloaderProgressBar.src = "./images/bar.png";
      				document.preloaderProgressBar = new Image();
      				document.preloaderProgressBar.src = this.preloaderProgressBar;
      				var preloaderLeft;
      				this.preloaderLeft = new Image();
      				this.preloaderLeft.src = "./images/left.png";
      				document.preloaderLeft = new Image();
      				document.preloaderLeft.src = this.preloaderLeft;
      				var preloaderRight;
      				this.preloaderRight = new Image();
      				this.preloaderRight.src = "./images/right.png";
      				document.preloaderRight = new Image();
      				document.preloaderRight.src = this.preloaderRight;
      				var preloaderTop;
      				this.preloaderTop = new Image();
      				this.preloaderTop.src = "./images/top.png";
      				document.preloaderTop = new Image();
      				document.preloaderTop.src = this.preloaderTop;
      				var preloaderBottom;
      				this.preloaderBottom = new Image();
      				this.preloaderBottom.src = "./images/bottom.png";
      				document.preloaderBottom = new Image();
      				document.preloaderBottom.src = this.preloaderBottom;
      				var preloaderLoaded;
      				this.preloaderLoaded = new Image();
      				this.preloaderLoaded.src = "./images/loaded.png";
      				document.preloaderLoaded = new Image();
      				document.preloaderLoaded.src = this.preloaderLoaded;
      				var preloaderUnLoaded;
      				this.preloaderUnLoaded = new Image();
      				this.preloaderUnLoaded.src = "./images/unloaded.png";
      				document.preloaderUnLoaded = new Image();
      				document.preloaderUnLoaded.src = this.preloaderUnLoaded;
      				imagePreloader(false, this.id, false, false);
      			}
      		else
      			{
      				if(document.preloaderProgressBar.readyState
      				&& document.preloaderLeft.readyState
      				&& document.preloaderRight.readyState
      				&& document.preloaderTop.readyState
      				&& document.preloaderBottom.readyState
      				&& document.preloaderLoaded.readyState
      				&& document.preloaderUnLoaded.readyState)
      					{
      						imagePreloader(true, this.id, false, false);
      					}
      				else
      					{
      						setTimeout("imagePreloader(false, "+this.id+", false, false);", 25);
      					}
      If you notice where it says readyState, I tried that instead of complete, but the thing is...

      <body onload="initial ize();"> calls the initialize function.
      The initialize function calls the imagePreloader function:
      imagePreloader( false, window.currentI mageId, false, true);
      The last true at the end makes this.preloaderL oading = true.
      Which then sends it into that first part...
      Then it calls itself again:
      imagePreloader( false, this.id, false, false);
      And since all conditions are false in the "if" statement, it goes to the last else.
      The last else has an "if" statement in itself.
      The if statement checks if all of the images preloaded it the else if statement in the first part of this code on this post... but the problem is... it gets stuck there, if someone could rework this code so that the:
      Code:
                      if(document.preloaderProgressBar.readyState
                      && document.preloaderLeft.readyState
                      && document.preloaderRight.readyState
                      && document.preloaderTop.readyState
                      && document.preloaderBottom.readyState
                      && document.preloaderLoaded.readyState
                      && document.preloaderUnLoaded.readyState)
      returns true... that would be one more step towards finishing this...
      ...because that's -where- it's stopping, not in the first part of imagePreloaded if statement, because that is skipped entirely.

      BTW I added line numbers to the right of the code viewer on my site... if that helps some...

      Comment

      • moltendorf
        New Member
        • Jul 2007
        • 65

        #4
        Anyone able to help me out?

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Instead of using readyState, use the non-standard complete property.

          Comment

          • moltendorf
            New Member
            • Jul 2007
            • 65

            #6
            .readyState and .complete aren't working atm.
            =/

            Comment

            • moltendorf
              New Member
              • Jul 2007
              • 65

              #7
              Figured out the issue to this like a year later!

              I should be assigning the images I have an event (like I did in my ShinyLink program I just posted an issue I was having with about).

              Code:
              var image = new Image ();
              image.src = './image.jpg';
              image.onload = function ()
              {
              // What to do.
              }
              I got a test script using this new knowledge at this location:

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Not sure why I didn't suggest that a year ago. Anyway, glad you've finally got it working and thanks for posting.

                Comment

                Working...