#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    43
    Rep Power
    34

    Scroll Pane scroll bars not working...


    Hey guys I have a scroll pane component that I dynamically add movie clip objects too (Which are actually pictures).

    However when I dynamically add the movie clip objects to the scroll pane the scroll bars don't appear.

    I have both scroll bars set to auto and I even tried adding in an event listener to update the scroll pane...

    Here is my code

    Code:
    public function Main() {
        scrollPane.addEventListener(Event.COMPLETE,updateScrollPane);
    }
    
    function updateScrollPane(event : Event) : void {
    trace("should be updating the scoll pane...");
    scrollPane.update();
    }
    
    //This function is called after the images have been loaded into flash, so to speak
    function onMovieClipLoaderComplete(event:Event):void
    {
    var loadedContent:DisplayObject=event.target.content;
    var loader:Loader=event.target.loader as Loader;
    			
    scrollPane.addChild(loader);
    
    }
    Like I said the scroll bars don't get updated and in fact the event for the scroll pane, IE updateScrollPane() never actually gets called!!!
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3164
    Hi, have you tried calling scrollPane.update() directly after the addChild call? The Event.Complete event will not get called since the scroll pane itself is already loaded. It will not get called when the images finish loading since they are not added to the scroll pane until after they have loaded, by that time the event would of already of been fired before they became children of the scroll pane.

    I'd sack off the scrollpanes COMPLETE event and just do:

    scrollPane.addChild(loader);
    scrollPane.update();
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    43
    Rep Power
    34
    Originally Posted by Tann San
    Hi, have you tried calling scrollPane.update() directly after the addChild call? The Event.Complete event will not get called since the scroll pane itself is already loaded. It will not get called when the images finish loading since they are not added to the scroll pane until after they have loaded, by that time the event would of already of been fired before they became children of the scroll pane.

    I'd sack off the scrollpanes COMPLETE event and just do:

    scrollPane.addChild(loader);
    scrollPane.update();
    I tried doing that and then I get the following error...

    RangeError: Error #2006: The supplied index is out of bounds.
    at flash.display:isplayObjectContainer/getChildAt()
    at fl.containers::ScrollPane/update()
    at Main/onMovieClipLoaderComplete() flash\fileUploader\Main.as:141]
  6. #4
  7. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3164
    oki, well lets re-jiggle it a bit then. Try adding the loaders to the scrollpane when you first create them. Then inside the onMovieClipLoaderComplete function do the scrollPane.update();

    Something else you can try is resizing the scrollpane. This was a bit of a hack from the AS2 version. The trick is you resize it by one pixel and then immediately resize it back to the original dimensions.
    Quis custodiet ipsos custodes?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    43
    Rep Power
    34
    Ok so I tried adding the loader as a scrollPane child in the onFileLoaded() function... I get the same error when I call scrollPane.update() in the onMovieClipLoaderComplete() event function.

    It seems really SILLY to me that a scroll pane component is so hard to get to actually scroll!!!

    I'm pulling my hair out.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    43
    Rep Power
    34
    Ok I couldn't figure out how to add file attachments to this website so I have uploaded my AS and FLA file to a zip found here....

    http://www.rc-monkey.com/tmp/fileUploader.zip

    I just figured it might be easier for you to understand my code if you can see the whole file.

    Thank a lot so far for all your time and help!
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    43
    Rep Power
    34
    Ok I have figured it out!

    The problem is that you can't add the pictures to the scrollpane using something like this...

    ScrollPane.addChild(AnImage);
    ScrollPane.update();

    This will give you an error because the ScrollPane.source member is EMPTY!!!

    So what you need to do is add children to a display object, and then set the source of the scrollpane to the be the display object. Kinda like this...

    Code:
    var myDisplay : DisplayObject = new DisplayObject();
    
    myDisplay.addChild(myChild1);
    myDisplay.addChild(myChild2);
    myDisplay.addChild(myChild3);
    myDisplay.addChild(myChild4);
    
    ScrollPane.source = myDisplay;
    ScrollPane.update();
    That should work for anyone who's having a similar problem!
  14. #8
  15. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3164
    ha, jolly good, thanks for posting back with the solution, glad you got it sorted ^_^
    Quis custodiet ipsos custodes?
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2005
    Posts
    43
    Rep Power
    34
    Originally Posted by Tann San
    ha, jolly good, thanks for posting back with the solution, glad you got it sorted ^_^
    No worries. I always find it annoying when I read a forum looking for an answer to a solution and someone posts that they've found the answer but they don't say what the answer is!!!

    Thanks for your help!

IMN logo majestic logo threadwatch logo seochat tools logo