开发者

AS3: Extending default ScrollBar component

开发者 https://www.devze.com 2023-01-04 12:31 出处:网络
I\'d like to adjust the width of the default ScrollBar that appears inside of a Flash ComboBox.From my research on various forums, it seems like the best approach would be to subclass fl.controls.Scro

I'd like to adjust the width of the default ScrollBar that appears inside of a Flash ComboBox. From my research on various forums, it seems like the best approach would be to subclass fl.controls.ScrollBar, which I've tried doing here:

package helpers {

  import fl.controls.ScrollBar;

  public class CustomScroller extends fl.开发者_JAVA百科controls.ScrollBar {

    public function CustomScroller() {
      super();
      trace("custom scroller in full effect!");
      width = 40;
    }  
  }
}

Then, in my library, I've taken the "ScrollBar" movie clip that appears upon initial creation of a ComboBox and changed the base class to "helpers.CustomScroller". I've got three ComboBox instances on the stage; however, none of them are showing anything but the default width, nor am I seeing the output from the trace() statement in my constructor.

Any idea why this isn't working? Thanks for your consideration.


I have only had to do this once, and don't want to do it any more. Basically, to accomplish this, I needed to create a copy of fl.controls.ScrollBar called fl.controls.WideScrollBar. You also need to modify fl.containers.BaseScrollPane and fl.containers.ScrollPane.

In WideScrollBar I overrode public static const WIDTH:Number

In WideBaseScrollPane you need to change the class of _verticalScrollBar and/or _horizontalScrollBar to be WideScrollBar. Then in my WideScrollPane, I overrode the calls to setStyle in the contructor to point to my custom class instances for skinning.


Add the scroll pane as a child to a Sprite, then scale that parent sprite. Scroll bars will adjust accordingly. If source of ScrollPane is now too big, scale by inverse of same scale factor.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号