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
New Developer
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified

Problem with loading images, Help !

Hi

 

i want to load a image in the application, but nothing got displayed, the following is the code

 

public class ImgTest extends Sprite
	{
		public function ImgTest ()	{
			var loader:Loader = new Loader;
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
			loader.load(new URLRequest("assets/sample.jpg"));

		}
		private function imageLoaded(event:Event):void	{
			var image:Bitmap = new Bitmap(event.target.content.bitmapData);
			addChild(image);
		}
	}

 

Please help ?

 

Developer
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Problem with loading images, Help !

If these are resources for your app, try to embed them in the application (you may embed many types of resources, fonts, images sounds - it is big fun!).

 

Here is some tutorial:

http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
New Developer
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified

Re: Problem with loading images, Help !

Thanks for the reply, i want to insert an image in my application , it will occupy half of the screen and the remaining screen i need to put some buttons there. Why my previous code is not working ? i found so many examples similar to the above i was coded. Any help ?
Developer
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Problem with loading images, Help !

Are you specyfing position of image and size of an image? Maybe newly created sprite does not have size or position, or it is empty (when image will not load - it will be empty and invisible).

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Problem with loading images, Help !

Have you tried using the QNX Image api? Here's the link to the ASDoc and it's usage:

http://www.blackberry.com/developers/docs/airapi/1.0.0/qnx/ui/display/Image.html
J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 29
Registered: ‎11-14-2010
My Device: Playbook

Re: Problem with loading images, Help !

@ramesh_bh I tried your sample code and it's working. Are you sure that your complete event handler is called? Maybe you just have wrong path to the image.

 

I created assets directory with image inside my src directory so it's compiled with application. Try to do the same and let us know if that solved your problem.

New Developer
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified

Re: Problem with loading images, Help !

Yes it was worked for me also, i have created assets folder under project not under src folder, sorry to trouble you all

Thanks again.