4 Replies Latest reply on Nov 12, 2007 8:46 AM by capnwhitey

    Help with Dynamic Slideshow

      I am a Flash novice but I've been trying my hand at building a dynamic slideshow for a friend's portfolio site. You can preview the porfolio page here.

      The arrows (prev/next) advance the images pulling from a directory using actionscript. I have attached the actionscript. It works quite nicely, but my question relates to the small thumbnails along the right side of the page.

      My question:
      When a visitor clicks on one of the thumbnails, how do I get the thumbnails to load the corresponding image into the movie clip (or stage) on the left? Currently, all of the thumbnails are linked to the images using GET URL.

      I haven't loaded all of the thumbnails yet as I wanted to see if anyone had any ideas before I start building the rest of the page.


        • 1. Re: Help with Dynamic Slideshow
          clbeech Level 3
          not bad, but a couple of things. The use of the keyword 'this' within your code could get you into a little trouble with scope. When used within a method it can apply to the Object on which the method has been called on, and not the main timeline scope, although it is still working for you here. Also it is being compounded by the fact that you have constructed your methods using prototyping, which further defines the scope of 'this' to the Object that the method is being applied to, again, still working for you here. Usually we would define 'named functions' (methods) to handle these oprations rather than using prototyping, since prototyping constructs a 'universal' method that comes part of the parent class that the prototype it is called on. With prototypes you can call a method on any instance at any given time from anywhere within the scope of your document, yet again, still working for you here ...

          I would remove all references of 'this' and construct these as named methods, rather than prototypes, and maybe save some problems down the road.

          But to the question:
          From within the thumbnail's on handler (which you must be setting up manually) you need to assign the pIndex to the value corrsponding to the thumb, and then call the 'changePhoto' method, and pass 0 for d.

          But because you have these built as prototypes you'll need ot be careful how you call the method, and assign the var value, I think:

          _level0.pIndex = #; //thumb index number

          just to make sure it's not being applied to the thumb's scope. Hope 'this' helps LOL!! :)
          • 2. Re: Help with Dynamic Slideshow
            capnwhitey Level 1
            Thanks very much for your reply, clbeech! Unfortunately, your descriptions of named methods vs. prototypes goes way over my head.

            Yes, I was assigning the GET URL tag to each thumbnail, and I'm at a loss of how to get the thumbs to load into the "photo" instance. I copied your suggested string into one of my thumbnails (see attached code). I'm obviously not utilizing the code correctly, and I'm unsure where/if I should modify the action script in the master scene to accomodate the new string. I'm sorry to be a nuisiance, but I'm sort of stabbing in the dark, so any and all help would be great!

            • 3. Re: Help with Dynamic Slideshow
              At the beginning of your code, pIndex is defined as a Number, whcih is zero; but in your button event, your redefine pIndex as a string. Since the changePhoto method oerrides pindex again anyways, that line in your button event does not do anything. pIndex seems to be an internal counter for which image is currently shown; according to your code you shouldn't have to mess with it directly. Try omitting the first line in your button event where you set pIndex, and just use the second line. If that doesn't work, try putting a few trace statements which read


              ...and see what you get. If the trace returns anything else than _level0, then you've got a scope issue on your hands.

              • 4. Re: Help with Dynamic Slideshow
                capnwhitey Level 1
                Thanks, Joe! I plugged in your code, but all it does is reload whatever image is currently loaded.

                As far as the "trace(this);" statement, do I place that in the button event or in the master scene actionscript? How would I customize the statement - something like this: