Playing an embedded FLV file in AS3 is something I keep seeing asked in forum after forum. (I know because I checked about 20 looking for the answer.)
Note: The onMetaData and onXMPData functions are required to be defined in this class.
After digging around for awhile I found a solution using Video and NetStream, here we go…
package { import flash.display.AVM1Movie; import flash.display.Loader; import flash.display.MovieClip; import flash.display.Sprite; import flash.events.Event; import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream; import flash.utils.ByteArray; ** * ... * @author John Fly */ public class Main extends Sprite { [Embed(source='../assets/demo.flv',mimeType='application/octet-stream')] private var myOpening:Class; public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point var myOpeningBytes:ByteArray = new myOpening(); var vid:Video = new Video(640, 400); addChild(vid); var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.client = this; ns.play(null); vid.attachNetStream(ns); ns.appendBytes(myOpeningBytes); } public function onMetaData(info:Object):void { trace("width: " + info.width); trace("height: " + info.height); } public function onXMPData(info:Object):void { } } }