Catching Dependency Retrieving Errors

Software: Away3D 4.x

Sam, Newbie
Posted: 21 June 2012 08:17 PM   Total Posts: 3

Hi all,

I am loading a .3ds file dynamically using the Max3DSParser. The .3ds file has a path to an image within it that defines it’s texture. Unfortunately, since I am loading these dynamically, I can’t guarantee that the image file is always going to be there.

When the file isn’t there the player crashes with an Error #2032: Stream Error. at away3d.library::AssetLibrary/onDependencyRetrievingError()

I am looking to catch these errors but it doesn’t seem to matter where I put my try catch, they are never caught. For instance:

try 
{
 loader
.loadurlRequestcontext );
}
catch ( error Error )
{
 trace
('error: '+error);

Help please.

   

Richard Olsson, Administrator
Posted: 22 June 2012 04:53 PM   Total Posts: 1192   [ # 1 ]

If you have a listener for the LOAD_ERROR event, the system should never throw errors (compare with how the way the Loader and URLLoader classes work in Flash.) However, there were some bugs with this, in particular when using the asset library (or Loader3D with the useAssetLibrary flag set to true.) These were fixed a couple of days ago and the fixes are in the release branch, to be merged into master in time for the mid-July Away3D 4.0 release!

So, as long as you’re using the latest version (where the bugs are fixed) and adding an event listener for the LOAD_ERROR event, you will not be getting any errors (just events instead.)

If you do nothing, the file will continue to load and replace the missing dependency if it can (missing textures will be replaced by a checker pattern.) If you want to abort the loading after the failure, you can call event.preventDefault().

The isDependency flag of the event object defines whether the load that failed was the main file (false) or just an external dependency (true).

   

Sam, Newbie
Posted: 25 July 2012 07:31 PM   Total Posts: 3   [ # 2 ]

In version Away3d v4.0.6 I have a listener on the Loader3d instance:

loader3d.addEventListener(LoaderEvent.LOAD_ERRORonLoader3dError);

*
snip*

private function 
onLoader3dError(event LoaderEvent) : void {
 Log
.logLogLevel.ERROR40'error: '+event.message);

This doesn’t prevent the error though. It is only prevented if I put event.preventDefault(); into that listener. While this solves my immediate issue, I suspect it is not how you want this to perform.

   

Richard Olsson, Administrator
Posted: 25 July 2012 09:48 PM   Total Posts: 1192   [ # 3 ]

The bugs I referred to in my previous post have been fixed in the Gold release. If you are using the 4.0 Gold release, you should be getting the expected behavior of no errors being thrown as long as you have an event listener for LOAD_ERROR anywhere in the event bubbling chain of the loader that encounters the error.

I’m not sure what you mean by “prevent the error”. The Event.preventDefault() method should just stop the loader from trying to load any more files (or do any more parsing.) If you don’t invoke preventDefault(), it should continue to load without throwing any more errors (if it can.)

Are you saying that it is still throwing errors even if you have the LOAD_ERROR listener? Are you using the Gold version?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X