12-31-2010 10:43 AM
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.
12-31-2010 10:55 AM
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.
12-31-2010 11:20 AM
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.