Flex4.6 项目调用AS 简单实现FLV 视频播放的问题?
本人新手 刚接触 Flex+AIR 移动开发
这是我的主视图页面
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="主页视图">
<fx:Script>
<![CDATA[
import MyActionScript.VideoPlay;
protected function btnplay_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
var vid : VideoPlay = new VideoPlay();
vid.Play("E:\\Youku Files\\download\\《魔兽世界:德拉诺之王》宣传片 标清.flv");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button id="btnplay" x="39" y="288" width="111" height="30" label="按钮"
click="btnplay_clickHandler(event)" enabled="true"/>
<s:Button id="btnstop" x="174" y="288" width="111" height="30" label="按钮"/>
</s:View>
这是调用的AS 文件
// ActionScript file
package MyActionScript{
import flash.display.Sprite;
import flash.events.AsyncErrorEvent;
import flash.events.Event;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public class VideoPlay extends Sprite{
public function VideoPlay(){
}
public function Play(file : String) : void
{
var nc : NetConnection = new NetConnection();
nc.connect(null);
var stream : NetStream = new NetStream(nc);
stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
stream.play(file);
var video : Video = new Video();
video.attachNetStream(stream);
this.addChild(video);
}
protected static function asyncErrorHandler(event:Event):void
{
// TODO Auto-generated method stub
}
}
}
但是 运行之后 点击按钮 播放没画面只有声音 这是怎么回事 求高手解答 this.addChild(video); 又是什么意思
把video添加到videodisplay里面