Although Flash started out as a vector animation tool, it has evolved to encompass a lot more. One of the features of Flash that has been very popular is its ability to play videos – YouTube is probably the best example of this. Away3D can also play videos as textures, allowing you to take your videos to a 3rd dimension.
There are some things to consider when trying to play videos in an Away3D application though. The first is that FLV files (the native Flash video file format), can not be embedded into an application. The Away3D VideoMaterial class takes the location of a FLV file, but you do have to be aware of the security restrictions that Flash places on loading resources. It also means that your 3D application can not be a single SWF file, but instead would require at least two files: the SWF file and the FLV file.
A simpler solution is to convert your videos into SWF files. A SWF file can be embedded, and the Away3D MovieMaterial class can use an embedded SWF file as the source of the texture.
For the convenience of a single SWF file, I prefer to use an embedded SWF file. But whatever way you go, you can use the ImToo FLV Converter to take your video files and covert them into either SWF or FLV files. The demo will convert files up to 3 minutes long, which should be plenty for most animated textures.
This demo shows you how to use an embedded SWF file as an animated texture. It extends the primitives tutorial, so if you want a description of the rest of the code please read that tutorial here.
ResourceManager.as
First the SWF file needs to be embedded. Flex understands and can transcode SWF files directly, so we can just embed it like any other image or music file. [code]
Creating an animated texture is as simple as passing a new instance of the embedded class to the MovieMaterial class. [code]
ApplicationManager.as
The MovieMaterial class can be passed to a 3D model as a material, just like any other material. [code]
Using embedded SWF files as the source for animated materials is very easy, and the free conversion tools available on the net make creating the SWF files a straight forward process.
Go back to Away3D Tutorials