Jump to content
Search Community

Graceful "intentional" failure of loaderMax instance?

BGoulette test
Moderator Tag

Recommended Posts

Hi, I have a loaderMax that looks for a jpg, etc. If the requested jpg doesn't exist, I want to draw a simple gray rectangle in its place. (If the users can't be bothered to tell me the correct location of the image they want to load, I'm not going to belabor the point! ;-) )

 

This seems to work -- the gray rectangle gets drawn -- but I'm still seeing an error in the output window. I included an onError handler when I appended an ImageLoader onto my loaderMax instance (that's what creates the gray rectangle), but I'm still seeing the following:

 

[pre]

Loading error on ImageLoader 'imgHeadshot' (): Error #2032: Stream Error. URL: file:///G|/Users/User/Documents/Folder/

[/pre]

 

I'm not sure if this is a LoaderMax thing or something more general, but is there anyway to avoid it? I tried wrapping the loaderMax.append and loaderMax.load statements in a try..catch, but that didn't do anything. Help?

 

PS: Here's what things look like right now:

 

private function loadHeadshot (strImage:String):void
{
// Load headshot image.
ldrHeadshot=new LoaderMax({name:"headshot", onComplete:onLmComplete, onError:onLmError});
ldrHeadshot.append(new ImageLoader(strImage, {name:"imgHeadshot", container:sprHeadshot, width:64, height:48, scaleMode:"proportionalInside", crop:true}));
ldrHeadshot.load();
}

private function onLmError (evt:LoaderEvent):void
{
sprHeadshot.graphics.beginFill(0x808080);
sprHeadshot.graphics.drawRect(0, 0, 64, 48);

onLmComplete();
}

private function onLmComplete (evt:LoaderEvent=null):void
{
sprHeadshot.x=SPR_WIDTH-(64+MARGIN);
sprHeadshot.y=MARGIN;
sprAnchor.addChild(sprHeadshot);
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...