# AS3 UIscrollbar: Adobe's example file throws an error

**URL:** <https://forum.kirupa.com/t/as3-uiscrollbar-adobes-example-file-throws-an-error/284982>\
**Category:** flash\
**Created:** [March 25, 2009, 7:38pm UTC](https://forum.kirupa.com/t/as3-uiscrollbar-adobes-example-file-throws-an-error/284982 "2009-03-25T19:38:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![somnamblst](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somnamblst](https://forum.kirupa.com/u/somnamblst)\
**Post date:** [March 25, 2009, 7:38pm UTC](https://forum.kirupa.com/t/as3-uiscrollbar-adobes-example-file-throws-an-error/284982/1 "2009-03-25T19:38:58Z")

</div>

The UIScrollbar in the Adobe example file is working, it is the loadText example that shipped with Flash 8, but it throwing the following error and on a page is triggering the Flash Player debugger.

Error #2007: Parameter child must be non-null.  
at flash.display::DisplayObjectContainer/addChildAt()  
at fl.controls::BaseButton/drawBackground()  
at fl.controls::LabelButton/draw()  
at fl.controls::Button/draw()  
at fl.core::UIComponent/callLaterDispatcher()

```auto
import fl.controls.UIScrollBar;

var my_txt:TextField = new TextField();
my_txt.x = 16;
my_txt.y = 55;
my_txt.wordWrap = true;
my_txt.multiline = true;
my_txt.width = 250;
my_txt.height = 170;
my_txt.background = false;
addChild(my_txt);

var my_sb:UIScrollBar = new UIScrollBar();
my_sb.x = my_txt.x + my_txt.width;
my_sb.y = my_txt.y;
my_sb.height = my_txt.height;
my_sb.scrollTarget = my_txt;
addChild(my_sb);

//Note: Download the TXT and CSS files to look at their structure. Use the URLs below.
//load text
function loadMyText():void {
    var url:String = "http://www.helpexamples.com/flash/text/sampletext.txt";
    
    var loadIt:URLLoader = new URLLoader();
    loadIt.addEventListener(Event.COMPLETE, textCompleteHandler);
    loadIt.load(new URLRequest(url));
}

function textCompleteHandler(event:Event):void {
    var urlV:URLVariables = new URLVariables(event.currentTarget.data);
    my_txt.condenseWhite = true;
    my_txt.htmlText = urlV.content as String;
    my_txt.styleSheet = myStyleSheet;
}

//apply stylesheet
var flash_css:URLLoader = new URLLoader();
flash_css.addEventListener(Event.COMPLETE, cssCompleteHandler);
flash_css.load(new URLRequest("http://www.helpexamples.com/flash/text/styles.css"));

var myStyleSheet:StyleSheet;

function cssCompleteHandler(event:Event):void {
    myStyleSheet = new StyleSheet();
    myStyleSheet.parseCSS(event.currentTarget.data);
    my_txt.styleSheet = myStyleSheet;
    loadMyText();
}

```
