I just added another experimental new feature: support for AIR 17's new "VideoTextures"!
Here's a sample of how to display the current camera video on the screen:
var camera:Camera = Camera.getCamera();
var texture:Texture = Texture.fromCamera(camera, 1, function():void
[The texture may only be used after the "onComplete" callback has been executed; until then, the size of the texture is unknown, so the texture will return '0' for width and height.]
To stream a video from a file or URL, you'll need a little bit more code; that's because the "NetStream" API is a little clunky. 😉
var nc:NetConnection = new NetConnection();
var file:File = File.applicationDirectory.resolvePath("bugs-bunny.m4v");
var ns:NetStream = new NetStream(nc);
var texture:Texture = Texture.fromNetStream(ns, 1, function():void
Beware that video textures are currently only supported in AIR (not the Flash Player) and only on Windows, OS X and iOS. Furthermore, you'll need AIR 17.
To find out if your current platform supports video textures, simply call:
trace("video texture support?", SystemUtil.supportsVideoTexture);
As a proof of concept, here's a screenshot of a video mapped onto a "Sprite3D" cube! Just imagine that the cat is moving. 😉
As always, I'd be happy if some of you could try out this new feature, and let me know how it works for you — and if you're content with the way the API was set up. Just beware that this is still a little buggy on the AIR side, so don't blame me for any problems. Or, well, at least not for all of them. 😉