Loading image at runtime rather than embedding it

Software: Away3D 4.x

Pokey, Newbie
Posted: 27 May 2013 05:46 AM   Total Posts: 23

Hello!

I am trying to load an jpeg image that is larger than 2048 pixels on one dimension which I intend to crop using UV mapping. I cannot get AssetLoader to behave. Using the following code:

_loader = new AssetLoader();
   
_loader.load(new URLRequest('../assets/earthsurface2.jpg')); 

gives me the error:

Error #2032: Stream Error. URL: app:/assets/earthsurface2.jpg
 
at away3d.loaders::AssetLoader/onRetrievalFailed()[/Users/pokey/Documents/Adobe Flash Builder 4.7/away3d-core-fp11_4_1_0_Alpha/src/away3d/loaders/AssetLoader.as:430]
 at flash
.events::EventDispatcher/dispatchEventFunction()
 
at flash.events::EventDispatcher/dispatchEvent()
 
at away3d.loaders.misc::SingleFileLoader/handleUrlLoaderError()[/Users/pokey/Documents/Adobe Flash Builder 4.7/away3d-core-fp11_4_1_0_Alpha/src/away3d/loaders/misc/SingleFileLoader.as:342]
 at flash
.events::EventDispatcher/dispatchEventFunction()
 
at flash.events::EventDispatcher/dispatchEvent()
 
at flash.net::URLLoader/onComplete() 

None of the examples show images loading at runtime, I am not even sure that AssetLoader is what I should be using.

Any ideas anyone?

TIA

   

Avatar
Fabrice Closier, Administrator
Posted: 27 May 2013 07:11 AM   Total Posts: 1265   [ # 1 ]

That’s because you do load from an AIR app. You need to resolve the url. Now it tries to load from an embedded directory.

   

Pokey, Newbie
Posted: 27 May 2013 05:39 PM   Total Posts: 23   [ # 2 ]

Thank you, it seems AIR does not support “../”, putting the jpg in the src folder solved the issue.

May I ask my next moronic question: What command do I use to convert the AssetLoaderToken into something the Cast.bitmapTexture() can use?

I am sorry to be a bother, but I cannot find any example code that loads image data in this manner.

TIA

   

Avatar
Fabrice Closier, Administrator
Posted: 27 May 2013 06:42 PM   Total Posts: 1265   [ # 3 ]

Since you use air, why not use Stream?

   

Pokey, Newbie
Posted: 28 May 2013 05:29 AM   Total Posts: 23   [ # 4 ]

I would like to use AssetLoader to keep the project as generic as possible in case I want to deploy it on some other platform later.

I have managed to get this far:

//massive texture setup
   
_loader = new AssetLoader();
   
_loader.load(new URLRequest('earthsurface2.jpg'),null,'hiresmap');
   
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonSceneResourceComplete);
   
_hiresmap AssetLibraryBundle.getInstance().getAsset('hiresmap') as BitmapTexture
earthMaterial2 = new TextureMaterialCast.bitmapTexture_hiresmap ) );
   
earthMaterial2.gloss 5;
   
earthMaterial2.lightPicker _lightPicker

and I am not getting any errors, but the globe shows as pure white. I have also tried scaling the UVs in case the texture was too hi res. Am I handling this properly or is there a better way?

TIA

   

hjimage, Newbie
Posted: 09 July 2013 09:44 AM   Total Posts: 4   [ # 5 ]

you must change the image formats before you load an image to the server which support the format. if it is a large one, you can crop images in vb.net with some software. make sure everything is not so complex.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X