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.
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.
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.
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 ]
[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);
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});