AssetEvent.ASSET_COMPLETE not triggering on Chrome/OpenGL

Software: Away3D 4.x

iansen, Newbie
Posted: 28 February 2013 08:58 AM   Total Posts: 17

I’m loading some .awd models like this:

Parsers.enableAllBundled(); 
  
AssetLibrary.loadData(new WheelModel(), null"WheelFL").addEventListener(LoaderEvent.RESOURCE_COMPLETE,  onResourceComplete);

AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete); 

Everything works great when using DirectX ... but when I try the same swf on Google Chrome (OpenGL) the RESOURCE_COMPLETE event doesn’t get triggered.

I’m using the RESOURCE_COMPLETE event handler to count how many of my models have been loaded and are ready to use. When all my models are
ready I start my main game loop (add a Enter Frame event).

Am I doing something wrong? I’m kind of new to away3d .
Is there a better way to know when a series of embedded models have been loaded?
My goal is to make a level loader of sorts…. load and add all the models to the scene before starting a level in my game.

Thanks.
I’m using away3d-core-fp11_4_1_0_Alpha.swc.

 

 

   

Qbrain, Member
Posted: 28 February 2013 04:26 PM   Total Posts: 92   [ # 1 ]

try this:

Parsers.enableAllBundled();
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceCompletefalse0true);

AssetLibrary.loadData(new WheelModel());

//or in your case:
//AssetLibrary.loadData(new WheelModel(), null, "WheelFL"); 


hope this helps.

-Q

 

   

iansen, Newbie
Posted: 01 March 2013 09:21 AM   Total Posts: 17   [ # 2 ]

Thanks for the reply.
I tried what you suggested but it still doesn’t work on Chrome.

   

Qbrain, Member
Posted: 01 March 2013 10:50 AM   Total Posts: 92   [ # 3 ]

it works for me so this specific code is not wrong, the problem must be in something else (for example the rest of the code, or your model).

Could you give some more code on what happends before/next etc.?

(like the imports, and the function you use to add the object to the view etc)

greets!

-Q

   

iansen, Newbie
Posted: 01 March 2013 10:58 AM   Total Posts: 17   [ # 4 ]

Here’s my class:

{
  
  
  [Embed
(source "../../assets/Models/CarBody.awd"mimeType "application/octet-stream")]
  
public static var CarModel:Class;
  
  
[Embed(source="../../assets/Models/Wheel.awd"mimeType="application/octet-stream")]
  

                
public static var WheelModel:Class;
  public static var 
loadedModels:uint 0;
  public static var 
CarObject:ObjectContainer3D ;
  public static const 
TOTAL_MODELS 5;
  public static var 
started:Boolean false;
  
  public static function 
Load (what:String
  
{
   started 
false;
   
Parsers.enableAllBundled(); 
  
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETE,onResourceComplete,false,0true);
   
CarObject  = new ObjectContainer3D();
   
Main.scene.addChild(CarObject);
   
   if (
what="Car"{
       
      
     AssetLibrary
.loadData(new CarModel(), null"car");
      
AssetLibrary.loadData(new WheelModel(), null"WheelFL");
      
AssetLibrary.loadData(new WheelModel(), null"WheelFR");
      
AssetLibrary.loadData(new WheelModel(), null"WheelBL");
      
AssetLibrary.loadData(new WheelModel(), null"WheelBR");
     
     
   
}
   
  }
  
  
static private function onResourceComplete(e:LoaderEvent):void 
  {
     
     loadedModels
++;
    if (
loadedModels >= TOTAL_MODELS{
      
if (!started{
      Main
.self.startLooping();
      
Main.cameraController = new SpringController(Main.cameraCarObject2,104);
      
Main.cameraController.positionOffset = new Vector3D(06580);
      
started true;
     
}
     }
  }
  
  
public static function onAssetComplete(e:AssetEvent):void 
  {
   
   
if (e.asset.assetType == AssetType.MESH{
     
    
var car_scale:Number 0.6;
    var 
wheel_y:Number 12;
       
    if (
e.asset.assetNamespace== "WheelFL"
     
      
var wFL:Mesh Mesh(e.asset);
      
wFL.wheel_y;
      
wFL.geometry.scale(car_scale);
      
NCar.m_tires[2].WheelBody.SetUserData(wFL);
      
Main.scene.addChild(wFL);
       
      
      
     
}   else if  (e.asset.assetNamespace== "WheelFR"
      
      
var wFR:Mesh Meshe.asset);
      
wFR.geometry.scale(car_scale);
      
wFR.wheel_y;
      
NCar.m_tires[3].WheelBody.SetUserData(wFR);
      
Main.scene.addChild(wFR);
       
       
      
     
else if  (e.asset.assetNamespace== "WheelBL"
      
      
var wBL:Mesh Meshe.asset);
      
wBL.geometry.scale(car_scale);
      
wBL.wheel_y;
      
NCar.m_tires[0].WheelBody.SetUserData(wBL);
      
Main.scene.addChild(wBL); 
       
      
     
else if  (e.asset.assetNamespace== "WheelBR"
      
      
var wBR:Mesh Meshe.asset);
      
wBR.geometry.scale(car_scale);
      
wBR.wheel_y;
      
NCar.m_tires[1].WheelBody.SetUserData(wBR);
      
Main.scene.addChild(wBR);
       
       
     

     
else if (e.asset.assetNamespace=="car"{
       
      
var CarModel:Mesh Meshe.asset); 
      
CarModel.geometry.scale(car_scale); 
      
CarModel.wheel_y;
     
      
CarModel.rotationX 0;
      
CarModel.rotationY 180;
      
NCar.m_body.SetUserData(CarObject);
      
CarModel.material.lightPicker Main.lightPicker;
      
CarObject.addChild(CarModel);
      
       
     
}  
      
     
   }
  }
  
 }

The Main.self.startLooping() function just adds a Enter Frame event listener.

Thanks for helping smile.

   

Qbrain, Member
Posted: 01 March 2013 11:15 AM   Total Posts: 92   [ # 5 ]

can’t see something atm. But could be me overlooking something.

Try tracing the onAssetComplete function. For example, try tracing the function and the stuff inside the if-statements. Then you can see if your model actually gets loaded. If that is the case, then the problem is in the adding to the stage instead of the loading part (good to know where the problem exactly is before solving it)

for example:

public static function onAssetComplete(e:AssetEvent):void 
  {
   trace
("1");
   if (
e.asset.assetType == AssetType.MESH{
     trace
("2");

    var 
car_scale:Number 0.6;
    var 
wheel_y:Number 12;
       
    if (
e.asset.assetNamespace== "WheelFL"
     trace
("3");

      var 
wFL:Mesh Mesh(e.asset);
      
wFL.wheel_y;
      
wFL.geometry.scale(car_scale);
      
NCar.m_tires[2].WheelBody.SetUserData(wFL);
      
Main.scene.addChild(wFL); 

btw, for your info, I use the onResourceComplete function for the same purpouse, and it works for me (even in chrome) so I am sure we are overseeing something here..

-Q

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X