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
Contributor
ShoulO
Posts: 10
Registered: ‎06-20-2011
My Device: curve 8520
My Carrier: Orange
Accepted Solution

Help!! how to put bitmap on screen??

I spend days trying to make super simple app with one bitmap on screen.

 

image.png

 

nothing works ;(

 

I tried this:

http://supportforums.blackberry.com/t5/Adobe-AIR-Development/Add-a-Bitmap-to-the-Screen/m-p/964803#M...

 

don't work. It says "Call to a possibly undefined method Image."

 

 

Can someone give/refer to super simple code example which works?

Im using Flash Builder 4.7

 

P.S.I made app with Flash Pro it was easy but seems this Flash Builder needs degree in rocket science

 

 any help appreciated! Thanks

 

 

Please use plain text.
Developer
shaan_softwaredvlpr
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Help!! how to put bitmap on screen??

Share your code snippet , by which we can understand what issue you are facing & your approach to add bitmap.
Please use plain text.
Developer
pyth
Posts: 506
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Help!! how to put bitmap on screen??

Sounds more like you haven't installed the SDK correctly, or the import is missing

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
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: Help!! how to put bitmap on screen??

Does sound like you are not connected to the BB SDK and have selected "Add platform specific libraries to library path" under the project settings.
Please use plain text.
Contributor
ShoulO
Posts: 10
Registered: ‎06-20-2011
My Device: curve 8520
My Carrier: Orange

Re: Help!! how to put bitmap on screen??

[ Edited ]

yes! one breakthrough -

after i did "Add platform specific libraries to library path" things changed - no more  erorr in code, but..

still doesnt work...

 

thats what i am doing:

 

1. Create new Actionscript Mobile Project. Name it 'kkk'

2. in project properties i click "Add platform specific libraries to library path"

3. in 'src' folder i import icon.png file

4. write the code:

 

package
{
	import flash.display.Sprite;
	import qnx.ui.display.Image;
	import qnx.fuse.ui.display.Image;

	[SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")]
	
	public class kkk extends Sprite
	{
		private var image:Image;
		
		public function kkk()
		{
			super();
			
			image = new Image();
			
			image.setImage("image.png");
			image.setPosition(10,10);
			
			addChild(image);
		}
	}
}

 now code is OK, no errors .but-

5. I run the code i get error:

 

An ActionScript error has ocured:

 

ReferenceError: Error #1065: Variable qnx.fuse.ui.styles::CoreStyles is not defined.
    at qnx.fuse.ui.theme::ThemeWhite/createCSS()
    at qnx.fuse.ui.theme::ThemeWhite()
    at qnx.fuse.ui.theme::ThemeGlobals$/getTheme()
    at qnx.fuse.ui.theme::ThemeGlobals$/http://www.qnx.com/2009/qnx/internal::getCSS()
    at qnx.fuse.ui.core::UIComponent/get css()
    at qnx.fuse.ui.core::UIComponent/init()
    at qnx.fuse.ui.display::Image/init()
    at qnx.fuse.ui.core::UIComponent()
    at qnx.fuse.ui.display::Image()
    at kkk()[C:\Documents and Settings\mmm\grybasssssssssss\kkk\src\kkk.as:17]

 

How to sort this out? thanks!

 

 BTW- my way of importing .png is : right mouse buton -->import --> general -> File System

 

 

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: Help!! how to put bitmap on screen??

Include the Skin and Device ANE.
Also, setting the image name to an external file name is not sufficient. If you are going to load external resources, you have to load them dynamically (URLLoader). If it is icons and such, you can embed them, which allows the app to start a lot faster.
Please use plain text.
Developer
pyth
Posts: 506
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Help!! how to put bitmap on screen??

[ Edited ]

Seems like there's still something wrong with the SDK.Since you are using Flash Builder 4.7, I think there was a different approach for installing the SDK

 

If you want to go for pure AS3, try this

(your image should be in a subfolder called 'assets')

 

package
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	[SWF(width="1024", height="600", backgroundColor="#404040", frameRate="60")]
	public class Test extends Sprite
	{
		[Embed(source='assets/image.png')]	public static const MyImage : Class;
		
		public function Test()
		{
			initBGR();
		}
		
		private function initBGR():void
		{
			var myImg:Bitmap = new MyImage();
			var mySprite:Sprite = new Sprite();
			mySprite.addChild(myImg);
			mySprite.cacheAsBitmap = true;
			addChild(mySprite);
		}
	}
}

 

 (not sure if 'static' has to be there)

 

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Please use plain text.
Developer
shaan_softwaredvlpr
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Help!! how to put bitmap on screen??

Please use plain text.
Contributor
ShoulO
Posts: 10
Registered: ‎06-20-2011
My Device: curve 8520
My Carrier: Orange

Re: Help!! how to put bitmap on screen??

whait a bit. I dont understand


you say i must include ANE. Which is native specific features of bb10 device. Does this mean this code will not work for other devises like android(or any other which supports AIR)?

 

is there a method to load an image without ANE?

 

i thought ANE is for something really specific - like acelerometer or like. but to load one inocent bitmap - do i really need ane?

 


also you sayed "load them dynamically" - how this is done?

 

 

in Flash Pro. I have library where i store items how this is achieved in "flash builder"?

I really  thought these simple things gonna be sraightforward.

Im moving from Flash Pro so , Flash Builder is new to me


Sorry for my ignorance. thanks for help.

 

 

Please use plain text.
Developer
shaan_softwaredvlpr
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Help!! how to put bitmap on screen??

Yeah to access code BB10 classes , you need to use qnxSkins.ane , if you are only in need of showing in png file , you can use UrlLoader , which will gives you its bitmapData , which you can add on a sprite object by adding bitmap of this bitmapdata .
But it just a workaround
Please use plain text.