Welcome!

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

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

Background image

hi

 

How to set background image to container.

Please use plain text.
Developer
jtegen
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.

 

PsedoCode:

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.

 

Please use plain text.
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

Re: Background image

Hey,

 

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.

 

i.e.

 

addChild(bgimage)

addChild(button)

addChild(title)

 

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.

 

Thanks.

 

 

Please use plain text.
Developer
peter9477
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!
Please use plain text.