Error "Scroll widget must have at least one child" - when coding Scrollt without xml
Hi RealyUniqueName,
i like your stablexui system and am currently using it for my project. i am running into a problem, where the Scroll Widget complains about not having at least one child, maybe you can help. Maybe there is something wrong with the child structure, because almost all examples of your documentation use xml.
(if this is not the right place for these kind of errors, i apologise in advance, please tell me if i can contact you somewhere else)
Thank you in advance, Thomas
here is the sample code that produces the error: "Error : Scroll widget must have at least one child" :
var bgSkin = new Paint(); bgSkin.color = 0xAAAAAA; bgSkin.border = 4; //bgSkin.borderColor = 0x003A00;
var sliderSkin = new Paint(); sliderSkin.color = 0x002200;
var conbit1:Bitmap = new Bitmap ( Assets.getBitmapData ("assets/img/ding.png") ); var conbit2:Bitmap = new Bitmap ( Assets.getBitmapData ("assets/img/ding2.png") ); var conbit3:Bitmap = new Bitmap ( Assets.getBitmapData ("assets/img/ding3.png") ); var conbit4:Bitmap = new Bitmap ( Assets.getBitmapData ("assets/img/ding4.png") ); var conbit5:Bitmap = new Bitmap ( Assets.getBitmapData ("assets/img/ding5.png") );
var content = UIBuilder.create ( Box ); content.widthPt = 100; content.childPadding = 5; content.paddingTop = 10; content.paddingBottom = 10; content.addChild ( conbit1 ); content.addChild ( conbit2 ); content.addChild ( conbit3 ); content.addChild ( conbit4 ); content.addChild ( conbit5 );
var scroller = UIBuilder.create ( Scroll ); scroller.widthPt = 100; scroller.bottom = 50; scroller.h = 400; scroller.skin = bgSkin; scroller.vBar.slider.skin = sliderSkin; scroller.hBar.visible = false; scroller.addChild( content ); mainWidget.addChild( scroller );
You need to specify a child for Scroll right in the UIBuilder.create() call instead of adding:
var scroller = UIBuilder.create(Scroll, { children: [content] });
...
Thank you for your fast help. As I have a few other questions concerning the usage of stablexui, would you give me a contact to you (maybe on openfl.slack.com or email)?
alex at stablex dot ru