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
Developer
Posts: 63
Registered: ‎12-10-2012
My Device: Blackberry 9900
Accepted Solution

How to set image as background of screen BB10...???

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.

_______________________________________________________
Help is available everywhere but you have to look at the correct place.
By Me :-)
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: How to set image as background of screen BB10...???

In our base Sprite, we add an Image object and set the background resource to that Image.
Developer
Posts: 63
Registered: ‎12-10-2012
My Device: Blackberry 9900

Re: How to set image as background of screen BB10...???

[ Edited ]

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.

_______________________________________________________
Help is available everywhere but you have to look at the correct place.
By Me :-)
Retired
Posts: 427
Registered: ‎02-22-2012
My Device: BlackBerry Z10, BlackBerry Dev Alpha C, BlackBerry PlayBook

Re: How to set image as background of screen BB10...???

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

 

Follow me on Twitter: @dustinmalik
-----------------------------------------------------------------------------------------------------
Keep up to date on BlackBerry development: http://devblog.blackberry.com/
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: How to set image as background of screen BB10...???

Or this:

[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.

New Contributor
Posts: 3
Registered: ‎10-06-2012
My Device: Playbook

Re: How to set image as background of screen BB10...???

<s:Rect id="backgroun" left="0" right="0" top="0" bottom="0"
>
<s:fill>
<s:BitmapFill source="@Embed('assets/picture.jpg')"/>
</s:fill>
</s:Rect>