Hi all,
I'm having a weird problem trying to use a video clip as a material on
a cube. It looks like the right code but I get an error message in
Flex Builder 3 (it's a standard AS3 project btw). Here's the code:
package
{
import away3d.cameras.*;
import away3d.containers.View3D;
import away3d.core.math.Number3D;
import away3d.core.utils.Cast;
import away3d.materials.BitmapMaterial;
import away3d.materials.VideoMaterial;
import away3d.primitives.Cube;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
public class SimpCube extends Sprite
{
private var viewport:View3D;
private var cube:Cube, cube2:Cube;
[Embed (source="../assets/metal.jpg")]
private var myTexture:Class;
private var myBitmap:Bitmap = new myTexture();
[Embed (source="../assets/temp.swf")]
private var myVidFile:Class;
public function SimpCube()
{
var cam:Camera3D = new Camera3D({zoom:6, focus:100,
x:0, y:0,
z:-200});
cam.lookAt(new Number3D(0, 0, 0));
viewport = new View3D({x:200, y:200, camera:cam});
addChild(viewport);
var myMaterial:BitmapMaterial = new
BitmapMaterial(Cast.bitmap(myBitmap));
cube = new Cube({width:150, height:150, depth:150,
material:myMaterial});
cube.x = -75;
cube.z = 500;
var myVidMaterial:VideoMaterial = new
VideoMaterial(myVidFile);
cube2 = new Cube({width:150, height:150, depth:150,
material:myVidMaterial});
cube2.x = 225;
cube2.z = 500;
viewport.scene.addChild(cube);
viewport.scene.addChild(cube2);
this.addEventListener(Event.ENTER_FRAME, renderThis);
}
private function renderThis(e:Event):void
{
cube.rotationX -=1;
cube.rotationY -=1;
cube.rotationZ -=1;
cube2.rotationX +=1;
cube2.rotationY +=1;
cube2.rotationZ +=1;
viewport.render();
}
}
}
The error messages though complain of quite a few syntax errors
(missing braces etc.) but I see nothing wrong and no line numbers are
specified. If I comment out all of the cube2 stuff but leave the swf
embed in and it still moans. It appears to be the swf embed line but
it finds the asset and appears to transcode it ok.
Any thoughts or an example of working code would be of great help!