Giving external variable through flashvar

Software: Away3D 4.x

Monguron, Newbie
Posted: 19 November 2011 02:28 PM   Total Posts: 27

Hello Guys,

My project loads models with the embed technique:

[Embed(source="/../embeds/tank.obj"mimeType="application/octet-stream")]
private var OBJData : Class; 

The index.html has the javascript code:

[removed]
  
var flashvars {
  }
;
  var 
params {
   menu
"false",
   
scale"noScale",
   
allowFullscreen"true",
   
allowScriptAccess"always",
   
bgcolor"",
   
wmode"direct" // can cause issues with FP settings & webcam
  
};
  var 
attributes {
   id
:"Away3daway3dexamplesbroomstick20a270c"
  
};
  
swfobject.embedSWF(
   
"Away3daway3dexamplesbroomstick20a270c.swf"
   
"altContent""400px""320px""11.0.0"
   
"expressInstall.swf"
   
flashvarsparamsattributes);
 
[removed] 

My question: how can I link the two together.
So if I want to load the house.obj instead of the tank.obj, and I select the file with a drop-down menu in my site (html), then what should I write in the acrion script. (I assume I should define a variable, which will be equal to the flashvar=“xxxxx”).

   

Avatar
80prozent, Sr. Member
Posted: 19 November 2011 03:47 PM   Total Posts: 430   [ # 1 ]

hi

in html/js you define your loadvars like this:

var flashvars={};
  
flashvars.var_yourvar="youVariableValue"


in as3 you get your var like this:

if (this.loaderInfo.parameters.var_yourvar{
   trace
(this.loaderInfo.parameters.var_yourvar);
 

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Monguron, Newbie
Posted: 20 November 2011 09:43 AM   Total Posts: 27   [ # 2 ]

Hi,

thanks for the feedback.

But how do I link the variable name into the Embed source?

Just put it into the source line? ... but then it will think that’s the name of the file, and it’s not a variable:

[Embed(source="/../embeds/adria/my_variable.obj"mimeType="application/octet-stream")]
private var OBJData : Class; 

 

   

Avatar
80prozent, Sr. Member
Posted: 20 November 2011 10:49 PM   Total Posts: 430   [ # 3 ]

hi

i think your problem is this:

you want a model-viewer where the html loads a swf and tells it which obj to load.

if you use the [Embed] tag, your swf does not load the obj on runtime, but inserts the obj file into the swf when then swf is created.

so if you would use [Embed] you would have to compile one swf for each obj and than load the different swfs per html/php. i wouldnt do that.

you should pass the obj-file name to the swf.
than you should use the away3d-loader classes to load the obj with the given name.


hope that helps

 Signature 

sorry…i hope my actionscript is better than my english…

   

Monguron, Newbie
Posted: 21 November 2011 08:17 AM   Total Posts: 27   [ # 4 ]

Thanks 80prozent,

Correct, that’s what I want (a model loader, which loads the .obj files in real-time).

How should I change the code from this:

[Embed(source="/../embeds/tank.obj"mimeType="application/octet-stream")]
private var OBJData : Class; 

any idea?
Thanks for your help!

PS: if this loading issue and flashvar variable forwarding is solved, then my loader is complete…

 

   

Avatar
80prozent, Sr. Member
Posted: 21 November 2011 04:38 PM   Total Posts: 430   [ # 5 ]

i didnt test this, but this is how it should work:

AssetLibrary.enableParser(OBJParser);   AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
AssetLibrary.load(new URLRequest("yourObject.obj"));


private function 
onAssetComplete(event:AssetEvent):void
  {
  
if (event.asset.assetType == AssetType.MESH)
   
{
    trace
("Mesh parsed");
                                
//setup materials, apply lights......

}
 Signature 

sorry…i hope my actionscript is better than my english…

   

Monguron, Newbie
Posted: 21 November 2011 04:50 PM   Total Posts: 27   [ # 6 ]

Hey 80prozent,

I just made a new thread, where you can see the complete code:
here

Thanks for your support ... you will be mentioned in the hall of fame already (beside Fabrice), that’s for sure smile

   
   
‹‹ Whats SecondaryUVData for?

X

Away3D Forum

Member Login

Username

Password

Remember_me



X