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
Deepu_George_Jacob
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Problem in image loading..

Hai i am trying to load images from a url .. But at first time image with is to be zero and after a while I got actual image width... I don't know how to solve this problem.. Anybody knows the solution for this problem please help me

 

Thanks 

Deepu

Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: Problem in image loading..

If you are using the qnx Image class your image is loaded asynchronously. The width and height of the image will be properly set once the image is loaded. You can listen for this event by adding an event listener:

 

import qnx.ui.display.Image;

...
var img:Image = new Image();
img.addEventListener(Event.complete, onLoaded);
img.setImage(someimage);
...

private function onLoaded(event:Event):void
{
    var img:Image = Image(event.target);
    trace("Image loaded! (" + img.width + "x" + img.height + ")");
}

 

 

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
Deepu_George_Jacob
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: Problem in image loading..

Each time i got different image width and height
Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: Problem in image loading..

What kind of image are you loading?

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
guru2000at
Posts: 101
Registered: ‎02-25-2011
My Device: Playbook, q5, z10
My Carrier: TM

Re: Problem in image loading..

have you tried using the (AS) Bitmap() class and the Loader() ?

 

something like (snippet):

 

...
var imgLoader:Loader = new Loader(); var imgURL:URLRequest = new URLRequest("image/path.png"); imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete); imgLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError); imgLoader.load(imgURL); ... private function onComplete(event:Event):void { trace("loading image complete"); var tmpImg:Bitmap = (LoaderInfo(event.target).content as Bitmap); }

 

________________
mappau Dev Team
blackberry@mappau.com
twitter: mappau
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: Problem in image loading..

I cant imagine you are getting different width and heights from the same image after loading. Verify the source image height and width and post your code snippet that might be causing this.
Please use plain text.
Developer
ChernyshovYuriy
Posts: 116
Registered: ‎11-18-2010
My Device: BlackBerry PlayBook
My Carrier: null

Re: Problem in image loading..

Can You post an example of the code You are trying to use please?
Please use plain text.