18 Replies Latest reply on Apr 24, 2006 3:33 PM by DavidMLevine

    Scroll pane and contentPath

    DavidMLevine
      I am trying to get a handle on the scroll pane. I got the effect I want on a movie clipe, but when I tried to put everything into a scroll pane, I got hung up. The problem seems to be in this loop with the contentPath command.

      for (var i = 1; i<=IconMap.length; i++) {
      IconClip = myScrollPane.contentPath.createEmptyMovieClip("btn"+i, i+1000);
      mcl.loadClip(IconMap
      , IconClip );
      //myScrollPane.contentPath.loadClip(IconMap
      , IconClip );
      ImageClip
      = myScrollPane.contentPath.createEmptyMovieClip("bt2"+i, i);
      mcl.loadClip(ImageMap , ImageClip);
      //myScrollPane.contentPath.loadClip(ImageMap , ImageClip);
      };

      Is this going to work? am I missing something simple or do I have to start all over again.

      Someone please give me a hand.. I have been unsuccesfull at getting any help at all here.

      Thanks,
      David
        • 1. Re: Scroll pane and contentPath
          flextnet
          I can't tell for sure without going through all the code, but it looks like the code is treating 'contentPath' as if it were a movie clip, which it's not. 'contentPath' is a string indicating the location of a jpg, swf or movie clip from the library to load into the scroll pain. After the content is loaded, the property 'content' is used to access the movie clip inside. So instead of this:

          IconClip = myScrollPane.contentPath.createEmptyMovieClip("btn"+i, i+1000);

          You'd probably have

          IconClip = myScrollPane.content.createEmptyMovieClip("btn"+i, i+1000);

          But you have to make sure 'content' is valid before you do this. Apparently the ScrollPane broadcasts a 'complete' event when the content has been loaded and initialized.

          • 2. Re: Scroll pane and contentPath
            DavidMLevine Level 1
            OK fair enough.. I know I tried that a million times, but it seems to work!

            now the content shows up, the scroll works just right, but the content is scaled with the scroll pane.

            if ((IconCount/2) == (Int(IconCount/2))) {
            myScrollPane.content._yscale = (int(((IconCount / 2) * 158) + 30)) * 100 / myScrollPane.content._height;
            } else {
            myScrollPane.content._yscale = (int(((IconCount + 1 / 2) * 158) + 30)) * 100 / myScrollPane.content._height;
            };

            Is what I have but what I really wanted is

            if ((IconCount/2) == (Int(IconCount/2))) {
            IconMovie._height = (int(((IconCount / 2) * 158) + 30));
            } else {
            IconMovie._height = (int(((IconCount + 1 / 2) * 158) + 30));
            };

            The first works correctly with the scrolling, but messes with the scale of the contents which I add after the fact. Any idea how to make the second work? It seems to not change anything. The content is correct, but the scroll bar is not functional now.

            Thanks again!
            • 3. Re: Scroll pane and contentPath
              flextnet Level 1
              Glad to be of help

              is 'IconMovie' the scroll pane content? If so, you might want to put a 'refreshPane()' in there somewhere too... (not sure)

              // scaling code
              //...
              myScrollPane.refreshPane();
              • 4. Re: Scroll pane and contentPath
                DavidMLevine Level 1
                I tried that and the invalidate(). The thing of it is, I am resizing the pane BEFORE adding the content.

                If I put a

                myScrollPane.refreshPane();

                after the

                for (var i = 1; i<=IconMap.length; i++) {
                IconClip = myScrollPane.content.createEmptyMovieClip("btn"+i, i+1000);
                mcl.loadClip(IconMap
                , IconClip );
                //myScrollPane.contentPath.loadClip(IconMap
                , IconClip );
                ImageClip
                = myScrollPane.content.createEmptyMovieClip("bt2"+i, i);
                mcl.loadClip(ImageMap , ImageClip);
                //myScrollPane.contentPath.loadClip(ImageMap , ImageClip);
                };

                then I get nothing showing as content... before it and nothing changes.
                • 5. Re: Scroll pane and contentPath
                  flextnet Level 1
                  ok I don't understand how 'IconMovie' (in your previous post) is related to the scroll pane (myScrollPane).
                  • 6. Scroll pane and contentPath
                    DavidMLevine Level 1
                    IconMovie is the instance name for the movie clip which is the content of myScrollPane. I need to resize the content, not the scrollpane.
                    • 7. Re: Scroll pane and contentPath
                      flextnet Level 1
                      If that's the case it seems you need to have a line like:

                      IconMovie = myScrollPane.content;

                      somwhere in your code (and I didn't see it after a quick scan).

                      You've got:

                      myScrollPane.contentPath =("IconMovie");

                      which looks like it's creating an instance of the 'IconMovie' library item.. but that doesn't mean you can then use IconMovie as an object (on the left side of the period) automatically.
                      • 8. Re: Scroll pane and contentPath
                        DavidMLevine Level 1
                        im sorry... It is actually the Linkage name for the clip. I have a blank movie clip in my library called myMC with the linkage identifier set as IconMovie. Does you previous comment still hold true?

                        thanks,
                        David
                        • 9. Re: Scroll pane and contentPath
                          flextnet Level 1
                          Yeah you still need to get a variable called IconMovie set equal to the scroll pane content before the scaling code will work:

                          IconMovie = myScrollPane.content;
                          if ((IconCount/2) == (Int(IconCount/2))) {
                          IconMovie._height = (int(((IconCount / 2) * 158) + 30));
                          } else {
                          IconMovie._height = (int(((IconCount + 1 / 2) * 158) + 30));
                          };
                          • 10. Re: Scroll pane and contentPath
                            DavidMLevine Level 1
                            OK.. so this is what Ive got, but I still have no scroll action. Everything seems fine except for that. It seems like there should be a simple problem. Can anyone spot it?
                            • 11. Re: Scroll pane and contentPath
                              DavidMLevine Level 1
                              Any ideas today?
                              • 12. Re: Scroll pane and contentPath
                                DavidMLevine Level 1
                                Did I mention its MX 2004 pro?
                                • 13. Re: Scroll pane and contentPath
                                  rlc5611 Level 1
                                  I thought with MX 2004 you should not use refreshpane. I thought the correct method was redraw(true) to update the pane after adding content. refreshpane was the old MX method which has different meaning in MX 2004.
                                  • 14. Re: Scroll pane and contentPath
                                    DavidMLevine Level 1
                                    OK, but I have tried myScrollPane.redraw(true) and IconMovie.redraw(true) to no avial.
                                    • 15. Re: Scroll pane and contentPath
                                      rlc5611 Level 1
                                      I haven't looked through your script to know exactly what you are trying to do but keep in mind that updating the scrollpane is time dependent. If you write a script to add content to the pane and then immediately redraw it, the pane may not yet be aware of its new content before the redraw occurs.

                                      As a simple test, make a temporary button on the stage and put your redraw(true) as a button action. Add your content and then click the button to see if the scrollbars are updated. If they are, then it means that the redraw is happening too soon. If that is the case, you will either need some type of preloader check before implementing the redraw (and preloader is complicated for the scrollpane) or else place the redraw inside a short setInterval delay. If the content is being loaded locally, the setInterval is good enough. if uploading to the web, preloader might be a better solution although, as I mentioned, the scrollpane has problems with reloaders and can be finicky.
                                      • 16. Re: Scroll pane and contentPath
                                        DavidMLevine Level 1
                                        Ok.. I made a button with the following code:
                                        on(click) {
                                        myScrollPane.redraw(true);
                                        IconMovie.redraw(true);
                                        _root.redraw(true);
                                        }

                                        clicking does nothing, so I am still in confusion.

                                        Bah!!

                                        Thanks
                                        • 17. Re: Scroll pane and contentPath
                                          DavidMLevine Level 1
                                          slight bump
                                          • 18. Re: Scroll pane and contentPath
                                            DavidMLevine Level 1
                                            im gonna cry