Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Regular Contributor
Posts: 90
Registered: ‎09-04-2009
My Device: Blackberry Z10
My Carrier: Airtel
Accepted Solution

Background image



How to set background image to container.

Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Background image

Create an image the size of the container, add it to the container, and then set the image to the source file.  If the image is already the size of the container, then you dont have to set the image size.



var bgimage : Image = new Image();
mycontainer.addChild( bgimage );
bgimage.setImage( 'assets/bg.jpg' );

If the image is embedded, the your setImage will allocated to that embedded image.

If the image is in another directory, other than your source directory, then that would be different.


Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

Re: Background image



Do we always have to put the background image in a container?

I have it on the main sprite, and then I just overlay/add new items on top of it.








Since bgimage is added first, everything else just goes on top.


Is there a reason why people use containers? I find no use for them really but maybe its just my app.

I just put everything relative to an x and y coordinate.





Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Background image

People use containers when they want a "fluid" layout, where items move around automatically to "reasonable" places without you having to manually set the position of each one.  This can have benefits in terms of reducing coding time, improving consistency of appearance, and more easily supporting automatic orientation adjustment (flip between portrait/landscape).


Depending on the apps, containers can either be very helpful, useless, or somewhere in between.  Your choice.  Best to learn a bit about them, then decide for yourself.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!