You can use a Loader and attempt a load as follows:
/**
* The Loader used to load images.
*/
private var _imageLoader:Loader = new Loader();
...
var urlRequest:URLRequest = new URLRequest(someURLString);
try
{
_imageLoader.load(urlRequest);
}
catch (imageLoadError:Error)
{
trace("Unable to load image at '" + someURLString + "': " +
imageLoadError.message);
}
You will need to listen to the loader for events. If it loads, your
source is ok, if not you will likely get the ioError event... unless you
have a security issue in which case you will catch the SecurityError
that gets thrown.
hth
Scott
bhaq1972 wrote:
How can I check if a the jpg source defined by a string really exists.
eg
var image1:Image = new Image();
var sHello:String = "images/hello.jpg";
if(sHello exists) // this is the bit i need help on
{
image1.source = sHello;
}
tia
bod