Need help to complete developed website: load external swf with loader as movieMaterial!!

Software: Away3D 3.x

edgar, Member
Posted: 19 October 2011 10:23 AM   Total Posts: 52

I have a code like this:

package
{
import away3d.loaders.Loader3D;
import away3d.materials.MovieMaterial;
import away3d.primitives.Plane;

import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.*;
import flash.events.ProgressEvent;
import flash.net.URLRequest;


public class SWFmaterial extends Away3DTemplate
{
 
 
  private var plane:Plane;
  private var movieMat:MovieMaterial;
 
  public function SWFmaterial()
  {
  super();
  }
 
  override protected function initScene():void
  {
  super.initScene();
  startLoad()
 
  }
 
  private function startLoad():void
  {
  var mLoader:Loader = new Loader();
  var mRequest:URLRequest = new URLRequest(“assets/PoloSWF.swf”);
  mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
  mLoader.load(mRequest);

 
  }
 
  private function onCompleteHandler(event:Event):void
  {
  plane = new Plane();
  plane.rotationX = 90;
  scene.addChild(plane);
  }
 
}
}


How can I complete this code so that it works?

   

edgar, Member
Posted: 19 October 2011 12:13 PM   Total Posts: 52   [ # 1 ]

How can I load an external or embedded PoloSWF.swf as MovieMaterial with the loader class on a plane.
I use Flash Builder 4 AS3 project.

Attached are the PoloSWF.swf, PoloSWF.as and the SWFmaterial.as.

Does anybody knows about it?

Thanks!
Edgar

 

File Attachments
files_(2).zip  (File Size: 385KB - Downloads: 168)
   

Richard Olsson, Administrator
Posted: 19 October 2011 01:04 PM   Total Posts: 1192   [ # 2 ]

When you load a SWF file using Loader what you get is a MovieClip, accessible through the content property of the Loader. So after COMPLETE, do this:

myMovie = MovieClip(myLoader.content);
myMaterial = new MovieMaterial(myMovie);
myMesh.material = myMaterial;

 

   

edgar, Member
Posted: 19 October 2011 01:19 PM   Total Posts: 52   [ # 3 ]

Thank you for replying.
I understand the theory and completed the code like this. But it still does not work.

public class SWFmaterial extends Away3DTemplate
{
  private var plane:Plane;
  private var movieMat:MovieMaterial;
  private var mLoader:Loader;
  private var myMovie:MovieClip;
  public function SWFmaterial()
  {
  super();
  }
 
  override protected function initScene():void
  {
  super.initScene();
  startLoad();
 
  }
 
  private function startLoad():void
  {
  mLoader = new Loader();
  mLoader.load(URLRequest(“assets/PoloSWF.swf”));
  mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
 

  }
 
  private function onCompleteHandler(event:Event):void
  {
  myMovie = MovieClip(mLoader.content);
  movieMat = new MovieMaterial(myMovie);

  plane = new Plane({material:movieMat});
  plane.rotationX = 90;
  plane.bothsides=true;
  scene.addChild(plane);
  }
 

 

 
}
}

What is missing?

 

   

Richard Olsson, Administrator
Posted: 19 October 2011 01:21 PM   Total Posts: 1192   [ # 4 ]

You need to explain the symptoms, i.e. in what way does it not work? Otherwise no one will be able to help you.

 

   

edgar, Member
Posted: 19 October 2011 01:38 PM   Total Posts: 52   [ # 5 ]

I just see a white screen.
I am really getting a depression meanwhile because I cannot get it solved to load this PoloSWF.swf as MovieMaterial on that plane. I know how to put any Material on that plane, but with this SWF it does not work.

Maybe you would spend me that code.

 

   

Avatar
80prozent, Sr. Member
Posted: 19 October 2011 01:49 PM   Total Posts: 430   [ # 6 ]

hi

have you tested if your loadet swf works fine when not using it as moviematerial (just add it to the normal flash 2d scene graph) ?

maybe your problem isnt the moviematerial, but the swf.

 

 Signature 

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

   

edgar, Member
Posted: 19 October 2011 01:50 PM   Total Posts: 52   [ # 7 ]

Anyway to do it with an embedded swf?

 

   

edgar, Member
Posted: 19 October 2011 01:52 PM   Total Posts: 52   [ # 8 ]

The PoloSWF.swf works fine

 

File Attachments
PoloSWF.swf  (File Size: 383KB - Downloads: 222)
   

edgar, Member
Posted: 19 October 2011 02:06 PM   Total Posts: 52   [ # 9 ]

is there a way to send you the project folder, so that you can see the code in total?

 

   

edgar, Member
Posted: 19 October 2011 02:16 PM   Total Posts: 52   [ # 10 ]

package
{
import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.core.base.Mesh;
import away3d.core.geom.Path;
import away3d.core.utils.Cast;
import away3d.events.MouseEvent3D;
import away3d.loaders.Max3DS;
import away3d.materials.BitmapMaterial;
import away3d.materials.ColorMaterial;
import away3d.materials.EnviroBitmapMaterial;
import away3d.materials.MovieMaterial;
import away3d.materials.WireframeMaterial;
import away3d.modifiers.PathAlignModifier;
import away3d.primitives.LineSegment;
import away3d.primitives.Plane;
import away3d.primitives.TextField3D;
import away3d.sprites.MovieClipSprite;

 
import flash.display.MovieClip;
import flash.display.Shader;
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.TimerEvent;
import flash.filters.ShaderFilter;
import flash.geom.Matrix3D;
import flash.geom.Vector3D;
import flash.utils.Timer;



import wumedia.vector.VectorText;


[SWF(width=“200”,height=“200”,backgroundColor=“0x222222”)]

public class PoloSWF extends Away3DTemplate
{
 
  [Embed(source=“assets/SimplePointLight.pbj”,mimeType=“application/octet-stream”)]
  protected var PixelBenderShader:Class;
 
  [Embed(source=“assets/vwpoloneu.3ds”,mimeType=“application/octet-stream”)]
  protected var PoloModel:Class;
 
  [Embed(source=“assets/polo02082011.jpg”)]
  protected var AS3Material:Class;
 
 
  [Embed(source=“assets/wheel.jpg”)]
  protected var WheelMaterial:Class;
 
  [Embed(source=“assets/street.jpg”)]
  protected var Marble:Class;
 
  //variables for car and wheel
  protected var vwPoloModel:ObjectContainer3D;
  protected var wheelModel:ObjectContainer3D;
  protected var Polo:ObjectContainer3D;
  protected var poloMesh:ObjectContainer3D;
  protected var model:Mesh;
  protected var wheelRF:Mesh;
  protected var wheelRFcontainer:ObjectContainer3D;
  protected var wheelLF:Mesh;
  protected var wheelLFcontainer:ObjectContainer3D;
  protected var wheelRB:Mesh;
  protected var wheelLB:Mesh;
 
 
 
 
 
  public function PoloSWF()
  {
  super();
  }
 
  protected override function initScene():void
  {
  super.initScene();
  PoloCar();
  addEventListener(Event.ENTER_FRAME,poloMove);
 
 
  }
 
  private function poloMove(event:Event):void
  {
  Polo.rotationY += 0.02*(-mouseX+stage.stageWidth/2);
  }
 
 
 
protected override function initEngine():void
  {
  view = new View3D();
  scene = view.scene;
  camera = view.camera;
  addChild(view);
 
  view.x = stage.stageWidth / 2;
  view.y = stage.stageHeight / 2;
  camera.z = -1500;
  camera.zoom = 15;
 
  stage.scaleMode= StageScaleMode.NO_SCALE;
  stage.frameRate = 40;
  }
 
  private function PoloCar():void{
  //Model of illustration on page
 
  var modelMaterial:EnviroBitmapMaterial = new EnviroBitmapMaterial(Cast.bitmap(AS3Material),Cast.bitmap(Marble),{reflectiveness:0.15,height:1024,repeat:false});
 
  poloMesh = Max3DS.parse(Cast.bytearray(PoloModel),
  {
    autoLoadTextures:false
  }
  );
  for each(var child:Mesh in poloMesh.children)
  child.material = modelMaterial;
  poloMesh.scaleX = poloMesh.scaleY = poloMesh.scaleZ = 1;
  poloMesh.z = -1*5;
 
 
  //wheel
  var wheelMaterial:BitmapMaterial = new BitmapMaterial(Cast.bitmap(WheelMaterial));
  wheelLF = new Wheel3();
  wheelLF.material = wheelMaterial;
  wheelLF.scaleX = wheelLF.scaleY = wheelLF.scaleZ = 0.063;
 
  wheelLFcontainer = new ObjectContainer3D(wheelLF);
 
  wheelLFcontainer.x = -3.4*5;
  wheelLFcontainer.y = -2.15*5;
  wheelLFcontainer.z =+4.85*5;
 
 
  wheelRF = new Wheel3();
  wheelRF.material = wheelMaterial;
  wheelRF.scaleX = wheelRF.scaleY = wheelRF.scaleZ = 0.063;
 
  wheelRFcontainer = new ObjectContainer3D(wheelRF);
 
  wheelRFcontainer.x = +3.4*5;
  wheelRFcontainer.y = -2.15*5;
  wheelRFcontainer.z =+4.85*5;
 
 
 
  wheelRB = new Wheel3();
  wheelRB.material = wheelMaterial;
  wheelRB.scaleX = wheelRB.scaleY = wheelRB.scaleZ = 0.063;
 
 
  wheelRB.x = +3.4*5;
  wheelRB.y = -2.15*5;
  wheelRB.z =-6.2*5;
 
 
  wheelLB = new Wheel3();
  wheelLB.material = wheelMaterial;
  wheelLB.scaleX = wheelLB.scaleY = wheelLB.scaleZ = 0.063;
 
 
  wheelLB.x = -3.4*5;
  wheelLB.y = -2.15*5;
  wheelLB.z =-6.2*5;
 
 
  Polo = new ObjectContainer3D(poloMesh,wheelRB,wheelLB,wheelLFcontainer,wheelRFcontainer);
  Polo.ownCanvas = true;
 
  scene.addChild(Polo);
 
  var shader1:Shader = new Shader(new PixelBenderShader());
  var shaderFilter1:ShaderFilter = new ShaderFilter(shader1);
 
  Polo.filters = [shaderFilter1];
 
 
  shader1.data.attenuationDecay.value = [1.07];
  shader1.data.attenuationDelta.value = [500];
  shader1.data.attenuationSpeed.value = [0.05];
  shader1.data.center.value = [240,80];
 
 
  Polo.rotationY = 180;
  Polo.scale(2);
  }
 
 
 
 
 
}
}

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X