我目前正試圖在flex上製作遊戲,而我遇到的其中一個問題是如何在開始時播放短動畫。這是我到目前爲止有:使用flex播放視頻,AS3
Game.mxml
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
name="Game"
backgroundColor="#000000"
horizontalAlign="center"
creationComplete="Init();"
enterFrame="UpdateFrame();"
paddingLeft="0"
paddingTop="0"
paddingBottom="0"
paddingRight="0"
width="800" height="600">
<mx:Script>
<![CDATA[
include "Game.as";
]]>
</mx:Script>
<mx:Canvas id="gamePanel" x="0" y="0" width="100%" height="100%" mouseDown="MouseDown(event)" mouseUp="MouseUp(event)" mouseMove="MouseMoved(event)"/>
</mx:Application>
和Game.as
import flash.display.*;
import flash.events.*;
import flash.external.ExternalInterface;
import mx.events.*;
import mx.controls.*;
[Embed(source="MyVideoClip.flv")] private var MyVideoClip:Class;
public function Init():void
{
var MyVideo:Video = new Video(800, 600);
addChild(MyVideo);
var qNetConnection:NetConnection = new NetConnection();
qNetConnection.connect(null);
var qNetStream:NetStream = new NetStream(qNetConnection);
MyVideo.attachNetStream(qNetStream);
qNetStream.client = new Object();
qNetStream.play(MyVideoClip);
}
private function UpdateFrame():void
{
}
private function MouseDown(event:MouseEvent):void
{
}
private function MouseUp(event:MouseEvent):void
{
}
private function MouseMoved(event:MouseEvent):void
{
}
我是相當新的Flex和AS3所以大多數代碼被扯掉網教程。每當我嘗試編譯它時,我都會得到:'錯誤:'MyVideoClip.flv'沒有延伸擴展,並且沒有提供mimeType。錯誤:無法轉碼'MyVideoClip.flv''
如果我在play()函數中刪除'embed'行並將MyVideoClip替換爲「MyVideoClip.flv」,則代碼無錯誤編譯,但是當我打開我得到的SWF只是一個黑屏。我在做什麼非常錯誤?
在此先感謝!
編譯器不知道如何轉碼的mime類型有限,所以將它嵌入到字節數組中,就像RobertL的答案所說的那樣,你可以通過NetStream播放它...... Mime類型:http:// stackoverflow.com/questions/6012772/as3-transcoder-mimetypes – SushiHangover