制作步驟:
1.新建一(yī)個FLASH文檔,設置舞台大(dà)小(xiǎo):300*260。
2.将組件MediaController和MediaDisplay拖入舞台,然後從舞台上删除。這樣做的目的是将這兩個組件載入庫中(zhōng),爲接下(xià)來用attachMovie()方法将MediaController和MediaDisplay組件載入舞台做好準備。
3.新建一(yī)層,命名爲function。在該層的第一(yī)幀上輸入如下(xià)AS代碼:
[code]
function init(){
flagNum = 1;
//播放(fàng)影片的标示
flvNum = 0;
attachController();
};
//将MediaController和MediaDisplay組件載入舞台并初始化
function attachController(){
//将MediaDisplay組件載入舞台并給定義實例名 "flvContainer" + flagNum
_root.attachMovie("MediaDisplay","flvContainer" + flagNum,2);
//設置組件初始參數
with(_root["flvContainer" + flagNum]){
_x = 0;
_y = 0;
setMedia(myArray[flvNum],"FLV");//設置播放(fàng)格式可以mp3等
}
//将MediaController組件載入舞台并給定義實例名 "flvController" + flagNum
_root.attachMovie("MediaController","flvController" + flagNum,1);
//設置組件初始參數
with(_root["flvController" + flagNum]){
_x = 0;
_y = 190;
activePlayControl = false;
controllerPolicy = "on";
//将MediaController和MediaDisplay組件相關聯
associateDisplay(_root["flvContainer" + flagNum]);
};
};
function playNext(){
//将MediaController和MediaDisplay組件從舞台上删除
_root["flvController" + flagNum].removeMovieClip();
_root["flvContainer" + flagNum].removeMovieClip();
flagNum += 1;
flvNum += 1;
//如果播放(fàng)到影片的最後一(yī)首,将flvNum = 0,意爲将從頭開(kāi)始播放(fàng)
if(flvNum == flvTotal) flvNum = 0;
//重新載入MediaController和MediaDisplay組件,并給一(yī)新的實例名
attachController();
//因爲每播放(fàng)完一(yī)個影片後MediaController和MediaDisplay組件從舞台上被卸載
//然後又(yòu)重新載入MediaController和MediaDisplay組件并給了另外(wài)一(yī)個實例名
_root["flvContainer" + flagNum].addEventListener("complete", myListener);
};
[/code]
4.新建一(yī)層,命名爲action,在該層第一(yī)幀輸入一(yī)下(xià)AS代碼:
[quote]
stop();
//數組myArray用來存儲 載入的XML文檔中(zhōng)的影片名稱
var myArray = new Array();
//影片的總數
var flvTotal:Number;
var myXml = new XML();
myXml.ignoreWhite = true;
myXml.load("list.xml");
myXml.onLoad = function() {
var e = myXml.firstChild.childNodes;
flvTotal = e.length;
for (var i = 0; i<flvTotal; i++) {
myArray.push(e[i].attributes["title"]);
}
init();
_root["flvContainer"+flagNum].addEventListener("complete", myListener);
};
var myListener = new Object();
myListener.complete = function(eventObject) {
playNext();
};
[/quote]
用記事本寫入下(xià)面内容作爲播放(fàng)列表,保存爲list.xml:
[quote]
<?xml version="1.0" encoding="utf-8" ?>
- <flvLists>
<item title="http://littleredflowers.com/shipin/yugao.flv" />
<item title="http://littleredflowers.com/shipin/huaxu-01.flv" />
<item title="http://littleredflowers.com/shipin/huaxu-02.flv" />
<item title="http://littleredflowers.com/shipin/huaxu-03.flv" />
</flvLists>
[/quote]
文件下(xià)載:http://www.kusochina.com/allan/blog/attachments/month_0604/62006423111925.rar
桂林唯創網絡flv網絡視頻(pín)播放(fàng)器的下(xià)載地址:http://www.93cn.net/downloads/flvplayer.rar
歡迎大(dà)下(xià)載使用.
1.新建一(yī)個FLASH文檔,設置舞台大(dà)小(xiǎo):300*260。
2.将組件MediaController和MediaDisplay拖入舞台,然後從舞台上删除。這樣做的目的是将這兩個組件載入庫中(zhōng),爲接下(xià)來用attachMovie()方法将MediaController和MediaDisplay組件載入舞台做好準備。
3.新建一(yī)層,命名爲function。在該層的第一(yī)幀上輸入如下(xià)AS代碼:
[code]
function init(){
flagNum = 1;
//播放(fàng)影片的标示
flvNum = 0;
attachController();
};
//将MediaController和MediaDisplay組件載入舞台并初始化
function attachController(){
//将MediaDisplay組件載入舞台并給定義實例名 "flvContainer" + flagNum
_root.attachMovie("MediaDisplay","flvContainer" + flagNum,2);
//設置組件初始參數
with(_root["flvContainer" + flagNum]){
_x = 0;
_y = 0;
setMedia(myArray[flvNum],"FLV");//設置播放(fàng)格式可以mp3等
}
//将MediaController組件載入舞台并給定義實例名 "flvController" + flagNum
_root.attachMovie("MediaController","flvController" + flagNum,1);
//設置組件初始參數
with(_root["flvController" + flagNum]){
_x = 0;
_y = 190;
activePlayControl = false;
controllerPolicy = "on";
//将MediaController和MediaDisplay組件相關聯
associateDisplay(_root["flvContainer" + flagNum]);
};
};
function playNext(){
//将MediaController和MediaDisplay組件從舞台上删除
_root["flvController" + flagNum].removeMovieClip();
_root["flvContainer" + flagNum].removeMovieClip();
flagNum += 1;
flvNum += 1;
//如果播放(fàng)到影片的最後一(yī)首,将flvNum = 0,意爲将從頭開(kāi)始播放(fàng)
if(flvNum == flvTotal) flvNum = 0;
//重新載入MediaController和MediaDisplay組件,并給一(yī)新的實例名
attachController();
//因爲每播放(fàng)完一(yī)個影片後MediaController和MediaDisplay組件從舞台上被卸載
//然後又(yòu)重新載入MediaController和MediaDisplay組件并給了另外(wài)一(yī)個實例名
_root["flvContainer" + flagNum].addEventListener("complete", myListener);
};
[/code]
4.新建一(yī)層,命名爲action,在該層第一(yī)幀輸入一(yī)下(xià)AS代碼:
[quote]
stop();
//數組myArray用來存儲 載入的XML文檔中(zhōng)的影片名稱
var myArray = new Array();
//影片的總數
var flvTotal:Number;
var myXml = new XML();
myXml.ignoreWhite = true;
myXml.load("list.xml");
myXml.onLoad = function() {
var e = myXml.firstChild.childNodes;
flvTotal = e.length;
for (var i = 0; i<flvTotal; i++) {
myArray.push(e[i].attributes["title"]);
}
init();
_root["flvContainer"+flagNum].addEventListener("complete", myListener);
};
var myListener = new Object();
myListener.complete = function(eventObject) {
playNext();
};
[/quote]
用記事本寫入下(xià)面内容作爲播放(fàng)列表,保存爲list.xml:
[quote]
<?xml version="1.0" encoding="utf-8" ?>
- <flvLists>
<item title="http://littleredflowers.com/shipin/yugao.flv" />
<item title="http://littleredflowers.com/shipin/huaxu-01.flv" />
<item title="http://littleredflowers.com/shipin/huaxu-02.flv" />
<item title="http://littleredflowers.com/shipin/huaxu-03.flv" />
</flvLists>
[/quote]
文件下(xià)載:http://www.kusochina.com/allan/blog/attachments/month_0604/62006423111925.rar
桂林唯創網絡flv網絡視頻(pín)播放(fàng)器的下(xià)載地址:http://www.93cn.net/downloads/flvplayer.rar
歡迎大(dà)下(xià)載使用.