开发者

Giving/obtaining a reference to (or the name of) a UIScrollBar in a TextArea

This is such a mindnumbingly simple question, but apparently all the forums where actionscript is discussed (or at least all the ones on google) aren't very well managed.

I have a textArea. It has a UIScrollbar. I want to be able to reference that scrollbar. I heard there's an update() function, and that may be able to save me from the inexplicable things this damnable UIScrollbar is do开发者_JAVA百科ing on its own.

(btw, actionscript = joke language)


When scrollbar is added to TextArea, it dispatches event ADDED. You can catch its scrollbar like this:

textArea.addEventListener(Event.ADDED, onTextAreaChildAdded);

private function onTextAreaChildAdded(event:Event):void {
    if (event.target is UIScrollBar) {
        //you got it
        var scrollBar:UIScrollBar = event.target as UIScrollBar;
    }
}

Event with scrollbar will be fired once. There is also many other stuff that adds into TextArea, so type check is needed.

Know ya jokes and be cool ^_^

Edit: wrong... Real solution seems to be just textArea.verticalScrollBar.


In your class just write:

private var usb:UIScrollBar = new UIScrollBar();

and voilá, usb is your reference.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜