Results 1 to 5 of 5

Thread: random images from folders..need help.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297

    random images from folders..need help.

    can someone look at this and tell me why its not working?

    Code:
    // Set slideShowSpeed (milliseconds)
    var slideShowSpeed = 5000
    
    // Duration of crossfade (seconds)
    var crossFadeDuration = 3
    
    var t
    var img
    var iNdx
    var sVal
    var q = 0
    var rpics = 0
    var preLoad = new Array()
    
    function loadshow(){
    
    iNdx = Math.round(Math.random() * 3) + 1
    
    for (y=1;y<=4;y++) { 
    
    	sVal = "images/random" + iNdx + "/"
    	for (x=1;x<=4;x++) {
      	img = sVal + "random" + x + ".jpg"
      	preLoad[rpics] = new Image()
     	preLoad[rpics].src = img.src
     	rpics++
    	iNdx++
    	}
    }
    
    function runSlideShow(){
       
       if (document.all){
          document.images.SlideShow.style.filter="blendTrans(duration=2)"
          document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
          document.images.SlideShow.filters.blendTrans.Apply()     
       }
    	
       document.images.SlideShow.src = preLoad[q].src
    
       if (document.all) {
          document.images.SlideShow.filters.blendTrans.Play() 
       }
    
       q = q + 1
       if (q > (rpics-1)) q=0
       t = setTimeout('runSlideShow()', slideShowSpeed)
    }

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    If you could post the code for the whole page I might be able to work it out. Alternativly, you could just describe excatly how you want the script and I'll write it.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297
    http://www.brentwoodacademy.com/indextest.shtml

    that is where you can see the rest of the page

    is what the script does is this:

    4 random folders named random1, random2, random3, random4.

    so it then picks a random folder then

    loads four images from that folder into an images array

    then loads the remaining folders after that in the sequence

    then when its ran it runs a slideshow script body_onload then shows the images array.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Don't know if this is the problem or not, but iNdx is being incremented in the loop for your x var, which I think is the pictures.
    Also, I don't see how iNdx is reset after reaching the last folder (folder4).... If it starts with Random3, then it will try to then load from Random4, then Random5 and then Random6.... there doesn't appear to be any check for when iNdx exceeds its limits.


    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Posts
    297

    Question

    i was being a nub and forgot to add back the line:

    Code:
    if (iNdx==5) iNdx=1
    after the line:

    Code:
    for (y=1;y<=4;y++) {
    I initially took it out for debugging. Any ideas here?

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