Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Scroll widget must have at least one child" - when coding Scrollt without xml #262

Open
flexibleflasher opened this issue Jan 30, 2017 · 3 comments

Comments

@flexibleflasher
Copy link

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 );

@RealyUniqueName
Copy link
Owner

You need to specify a child for Scroll right in the UIBuilder.create() call instead of adding:

var scroller = UIBuilder.create(Scroll, { children: [content] });
...

@flexibleflasher
Copy link
Author

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)?

@RealyUniqueName
Copy link
Owner

alex at stablex dot ru

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants