2 Replies Latest reply on Jul 23, 2010 6:35 AM by ozDiGennaro

    How do I build a Scroller from scratch in Actionscript?

    ozDiGennaro Level 1

      I have a hierarchy of objects in my Actionscript.  I use Actionscript because all objects are dynamic, built at run-time on the basis of data from the server.

       

           Scroller

                Group

                     SxText (my class) is a subclass of RichEditableText which implements IViewPort

       

      Typical code is:

       

      public class SxText extends RichEditableText

      ...

       

                  sxText = new sxText(....);

       

                  scroller = new Scroller();
                  scroller.setStyle("horizontalScrollPolicy","off");
                  scroller.setStyle("verticalScrollPolicy","on");  

       

                  group = new Group();
                  group.addElement(sxText);
                 
                  scroller.viewport = group;

       

      It looks great and I can control location and size, as well as detect the events that I'm interested in.

       

      But, the scroll bar thumb fills the vertical space of the bar.

       

      I've tried many methods to enable or to set viewport content size, but the following code has no effect.

       

                  scrollerSkin = ScrollerSkin(scroller.skin);
                  scrollBar = scrollerSkin.verticalScrollBar;
                  vbarSkin = VScrollBarSkin(scrollBar.skin);
                  thumb = vbarSkin.thumb;
                 
                  vbarSkin.addEventListener(MouseEvent.CLICK,scrollBarEvent);
                  vbarSkin.setContentSize(sxText.width,sxText.height);

       

      I'm guessing that I'm missing the one method that will do it.  Thanks.