6 Replies Latest reply on Aug 10, 2007 11:48 AM by ab1301

    Buggy Scroll Buttons in slideshow app

    ab1301
      I have no prior programming experience, and I am trying to build a slideshow program for my site. I am simultaneously amazed at how easy it is to do things I think are complex in Flex, and frustrated at how difficult it is to do some things I think should be simple or even built in. Most of my problems I have been able to figure out from looking at examples of code similar to what I want, but I haven't been able to figure out how to make buttons to control my list of thumbnails.

      I have a set of thumbnails loaded from a Flickr photoset in an itemRenderer in a horizontalList, and I want to use buttons to scroll through the list and to select different items in a slideshow. On their own, the buttons work fine, but when I scroll to the end using the fast scroll buttons, then select an item with the cursor, the item selector buttons no longer work right--they start skipping items in a weird way. I have attached the code I'm using for the scroll and item selector functions. I have looked everywhere for a solution, and tried many different ways of doing this, but I am stuck.

      So my main question is:

      (1) what do I have to do to stop the buggy behaivor? Please keep in mind that I have 0 programming experience, so please try to keep your explanation as detailed and explicit as possible.

      My other less pressing questions are:
      (2) What do I use so that I do not have to type in the total number of items in the list? EDIT--I solved this one myself, by using maxHorizontalScrollPosition. duh.;

      (3) is there an easy way to either have the list scroll when the selector buttons select an item off screen, or have the item selected item always be in the center of the screen? EDIT -- I solved this one too using scrollToIndex(photoList.SelectedIndex), after the showNext() or showPrevious() functions. It doesn't work exactly the way I want, but close enough.

      (4) can someone point me to an example of code that allows the rest of the large images to be preloaded while the user is looking at a particular photo, or some similar code I could use to extrapolate how to do such a thing?

      (5) would the buggy scroll buttons be considered a bug in Flex Builder or is my code screwed up?


        • 1. Buggy Scroll Buttons in slideshow app
          ab1301 Level 1
          Here is the full code for the application, minus my flickr api key and photoset id (which go in the fickrURL variable) and my button skins. The databinding works fine, as does the smooth image function, if anyone is looking for that stuff (actually, I spoke too soon. Image smoothing was working, but now its not. I'm not sure what happened). There's also a cool little options pop up with myspace code, download full size, and open full size in new window.

          • 2. Re: Buggy Scroll Buttons in slideshow app
            ab1301 Level 1
            I've changed the scrollLeftFast(), scrollRightFast(), showNext(), and showPrev() functions to if(){} else{} expressions. This has dramatically reduced the buginess of the buttons. Before the buttons were consistently buggy when used together. Now, they are only buggy when the buttons are pressed in rapid succession. I suppose I could find a way to keep the application from listening to rapid-fire clicks, but I would rather have it work properly no matter how fast the mouse is clicked. Any ideas how to do this?
            • 3. Re: Buggy Scroll Buttons in slideshow app
              joan_lafferty Adobe Employee
              It would helpful if you put a link to show the problem. Its hard to visualize what is going on here. When you post a link, can you write the steps to reproduce your problem.

              If you think you are running into a bug, please file it at: http://bugs.adobe.com/flex. This is a better place for uploading application files.

              Thanks,
              Joan Lafferty
              Flex SDK QA
              • 4. Buggy Scroll Buttons in slideshow app
                ab1301 Level 1
                Well, here's the link to the application as it stands now: http://www.dukeofclubs.com/acoustikzoo/
                If it doesn't load at all, the problem is with my horrible godaddy server, which I am in the process of changing. Just try again later.

                Changing the if(){} if(){} to if(){} else{} in the scroll functions got rid of 99% of the problem. It went from being there all of the time before, to now only coming up very very rarely, usually when you scroll to the end very rapidly, then try to scroll back.

                Frankly, I'm not sure if it is a bug or not, because I am not a programmer. Logically, "if, if" makes as much sense to me as "if, else," but for all I know "if, if" is an invalid expression, and that is what caused part of the problem. Similarly, I'm not sure if there is something else in my code that is invalid that is causing the remaining part of the problem. So I don't know if it is a bug or not... you tell me--look at the scrollLeftFast() function, for example. Should changing that from "if if" to "if else" make a difference? If so, then the problem was with my code, else { I guess there is a bug. }
                • 5. Buggy Scroll Buttons in slideshow app
                  GordonSmith Level 4
                  I'm able to rapidly click the >> button to scroll to the end, and then rapidly click the << button to scroll to the beginning, over and over. So I guess I can't repro the problem.

                  Code like example 1 below makes no sense, because if a is negative, the first "if" fails and execution skips the entire block in { ... } after that first "if". So it won't execute the negative-check and doSomethingElse(), which is what you want. The correct way to write it is as in example 2. If the "if" test succeeds, it executes the block after "if". If the test fails, it executes the block after "else".

                  • 6. Buggy Scroll Buttons in slideshow app
                    ab1301 Level 1
                    It doesn't happen all the time. In fact, whenever I try to specifically reproduce it, I usually fail. Then, later I'll be randomly clicking around (to see how the progress bar is working, for instance) and the buttons stop working right. It doesn't happen very often, and I can't come up with a sequence that reproduces it reliably.

                    Regarding your examples, I get the reason the first example was wrong, and the second example is the way it is coded now. But the way it was before was not like your example 1, it was like the example set forth below, which would seem to work even under your explanation. Incidently, it DID work, when either the scroll[Right/Left]Fast function OR the show[Next/Prev] functions were used, it was only buggy when the two were used in conjunction (i.e. scrolling all the way to the left, then selecting an item, and hitting the showNext button).

                    Anyway, if you're interested at all, I'll post the new code when I get home.