A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: CS3 ScrollPane...uh...stupid?

  1. #1
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136

    CS3 ScrollPane...uh...stupid?

    I haven't had call before tonight to deal with the CS3 ScrollPane component, but I just assumed it would work like the AS2 component. And, uh...no.

    In AS2 I always just built the MC I needed to be scrollable and then set it as the .content of the ScrollPane. So now SPs can only take URL data and you can't replace their content and invalidate them...? Is that right?! There's got to be a way of loading a Sprite into a ScrollPane that I'm just missing, right? Please tell me this isn't some nasty way of making people move over to Flex or I'm going to blow my mind out, I have about ten hours to get this code finished and didn't count on building my own scrollpane component...

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    This is all you need to write when you have a MovieClip in your library:
    var myMC:Mc1 = new Mc1();
    myScroll.source = myMC;
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Multitouch Aficionado
    Join Date
    Mar 2006
    Posts
    275
    cancerinform is right. Remember to add the component to your library first, though, or it won't compile.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    Los Angeles
    Posts
    86
    how do i invalidate the scrollpane once the dynamic clip is loaded?

    the problem is that even though the contents are larger than the scrollpane, the scrollbar is missing because the instance it loads, thereis nothing in the dynamic clip.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    Los Angeles
    Posts
    86
    1. create class "glo.as":

    package {
    public class glo {
    public static var movieLoaded:Boolean = false;
    }
    }


    2. Import the class to the dynamic clip as well as the stage where the scrollpane is like:

    import glo;

    The above line assumes the as file is in the same directory as the fla file.

    3. set the trigger in the dynamic clip(i put this after the loop that generates the thumbnails or whatever you are dynamically adding:
    glo.movieLoaded = true;

    4. put this code in the same frame where your scrollpane is:

    addEventListener(Event.ENTER_FRAME, checkLoaded);
    function checkLoaded(x)
    {
    var test = glo.movieLoaded;
    if(test == true)
    {
    glo.movieLoaded = false;
    completeHandler(x);
    }
    }
    function completeHandler(event:Event):void
    {
    aSp.update();
    }

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    Los Angeles
    Posts
    86
    I'm still wrestling with as3, but this does work very nicely for me.

    the x in the function call(x) does nothing, but if I don't put something there I get errors.

    If there is an easier way to do all of this, someone please post a better solution.

  7. #7
    Multitouch Aficionado
    Join Date
    Mar 2006
    Posts
    275
    Use Event.ADDED_TO_STAGE and you don't have to do that checkLoaded() stuff.

    If I have a function I need to call from an event listener, but I don't use the event reference in the function, I do this:

    function calledFromEventOrOtherFunction(... args)

    ... args will let the event listener pass event without causing an error, but will let you call the function with no arguments as well.

    That said, you ought to do this for your last function:

    Code:
    function completeHandler(event:Event){
         if (event.target.parent is ScrollPane){
              ScrollPane(event.target.parent).update();
         }
    }
    That way, if you ever need to put that clip directly on the stage, you don't get errors about update not found.

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

HTML5 Development Center