Search code examples
actionscript-3actionscriptaway3d

AS#3 Loading SWF into SWF


Im trying to load an swf into a 3D Objectcontainer.Im using Away3D (gold)

Basically i have loaded an object into a 3d Container, now i would like to load an swf inside that same container. I would now have my object and a SWF inside the same container so if i rotate the container so will my SWF.My swf only consist of text for now its just a test...

The loading method im using is an array... Any ideas?

my error:

    TypeError: Error #1034: Type Coercion failed: cannot convert 
  flash.display::MovieClip@30ee0e41 to away3d.containers.ObjectContainer3D.

Solution

  • Away3D 4, is a bit more difficult. But I'll try to point you in the right direction.

    You need to create a Mesh out of Geometry and Material.

    The Material has a texture with your MovieClip. The Geometry is a PlaneGeometry

    The Mesh is the Object3D instance you need to add to your ObjectContainer3D.

    You're code would look something like this:

    var bitmapData:BitmapData = new BitmapData( mc.width, mc.height, false, 0x000000 );
    var texture:BitmapTexture = new BitmapTexture( bitmapData );
    var material:TextureMaterial = new TextureMaterial( texture, true );
    
    var geometry:PlaneGeometry = new PlaneGeometry( mc.width, mc.height );
    
    var planeMesh:Mesh = new Mesh( geometry, material );
    
    _3dcontainer.addChild( planeMesh );
    

    Now for the MovieClip to animate, you need to update the bitmap of your texture:

    mc.addEventListener( Event.ENTER_FRAME, updateTexture );
    
    private function updateTexture( e:Event ):void {
        texture.bitmapData = new BitmapData( mc.width, mc.height, false, 0x000000 );
    }
    

    Again, I did not test this, and it's long ago since I used Away3D 4. Just don't forget to import the used classes.

    Just have a good look in the docs: http://away3d.com/livedocs/away3d/4.0/