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
Posts: 18
Registered: ‎03-03-2011
My Device: Not Specified

Unable to load icon that is present in a local folder.

I am new to this and have been trying to load the icon to a button but I always get a "URL Not Found" or " Unable to load the file" error. Where should I actually place my .jpg file so that I can load it to the button?How can I direct the code to chose my icon file from that path?

 

Below is my code:

 

 

import flash.filesystem.File;
import qnx.ui.buttons.IconButton;

var iconPath:String = 'file:/' + File.applicationDirectory.nativePath + '/closeIcon.jpg';
closeButton.setIcon(realPath);

 

 

 

I have tried placing my closeIcon.jpg file at all relevant paths I can think of but nothing helps.

 

Thanks

HV

 

 

Developer
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520
My Carrier: Software Developer

Re: Unable to load icon that is present in a local folder.

I think in your case it's a better way to embed the image to your application.

 

public class Main extends Sprite
{    
	private var myButton:IconButton;
        
        [Embed(source = 'closeIcon.jpg')] public var closeIcon : Class;
	
	public function Main():void
	{
		myButton = new IconButton();
		myButton.setIcon(new closeIcon());
		
		addChild(myButton);
	}
}	
	

 something like this, not time for testing Smiley Wink

 

regards

 

Levi

 

Highlighted
Contributor
Posts: 18
Registered: ‎03-03-2011
My Device: Not Specified

Re: Unable to load icon that is present in a local folder.

I used the icon in .png format and it worked simply by using:

 

 

button.setIcon('closeIcon.png');

 

 

Thanks for you help.