12-12-2012 12:12 PM
We all have seen textures or commonly say images set as background for apps. In my app I need to set an image as it's background. I did look into BB 10 documentation but I couldn't find anything useful. If anyone have any idea please share it. Thanks in advance.
Solved! Go to Solution.
12-12-2012 12:32 PM - edited 12-12-2012 12:42 PM
Could you please explain with code that will be more helpful.. In my code there is
[SWF(width = "somevalue", height="somevalue", background="#fffff")]
In place of that colour code i tried loading my image source like 'background = "image/one.png" ' but it ended up in error.
Thanks in advance.
12-12-2012 01:53 PM
You could use a 9 slice scaled image for multiple resolutions.
[Embed(source="assets/Book_background.png", scaleGridTop="14", scaleGridBottom="17", scaleGridLeft="1", scaleGridRight="767")]
private var background : Class; private var myBG:Sprite = new background(); myBG.width = stage.stageWidth; myBG.height = stage.stageHeight; addChild(myBG);
12-12-2012 01:56 PM
[Embed(source='assets/bg.jpg')] private var bg_img : Class; private var bg : Image = new Image(); ... this.bg.setImage( new bg_img() ); this.addChild( this.bg );
This assumes the resource is sized properly. Like the idea to have it scale to fit, but some backgrounds may not look good if scaled too much.