有XML和AS3的问题,我的XML文件有问题吗? (XML解析器失败:元素格式错误。)

时间:2017-05-09 22:18:01

标签: xml actionscript-3 flash

好,

因此,我制作了一个Flash应用程序,其中包含一些缩略图按钮,点击它们时需要播放不同的视频。我一直收到错误:

TypeError:错误#1090:XML解析器失败:元素格式错误。

at MediaPlayer2_fla::MainTimeline/xmlLoadedVid()[MediaPlayer2_fla.MainTimeline::frame3:25]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

我认为这意味着XML文件有问题而不是我的AS3代码,但我无法弄清楚它是什么。

AS3看起来像这样:

var vidList_XML:XML;
var vidNum:int = 0;
var currVid:String;
var vidLoader:URLLoader = new URLLoader();

vidLoader.load(new URLRequest("/ASSETS/XML/vidlist.xml"));
vidLoader.addEventListener(Event.COMPLETE, xmlLoadedVid);

function xmlLoadedVid(e:Event):void{
    vidList_XML = new XML(vidLoader.data);

    vid1.addEventListener(MouseEvent.CLICK, pickVid);   

    //vidPlayer.addEventListener(Event.COMPLETE, nextVid);
    //vidPlayer.source = vidList_XML.vid[vidNum].file;


    }



function pickVid(e:MouseEvent):void {
    switch (e.currentTarget.name){
        case "vid1":
            vidNum = 0;
        currVid = vidList_XML.vid[vidNum].file;     

        break;
        }

        var uiRequestVid: URLRequest = new URLRequest(currVid);
        vidLoader.load(uiRequestVid);
        }

和XML:

<?xml version="1.0" encoding="utf-8"?>

<videos>

    <vid>
        <file>ASSETS/MOVIES/vid1.mp4</file>
        <name> 1 </name>
    </vid>

  <vid>
    <file>ASSETS/MOVIES/vid2.mp4</file>
    <name> 2 </name>
    </vid>

  <vid>
    <file>ASSETS/MOVIES/vid3.mp4</file>
    <name> 3 </name>
    </vid>

  <vid>
    <file>ASSETS/MOVIES/vid4.mp4</file>
    <name> 4 </name>
    </vid>

  <vid>
    <file>ASSETS/MOVIES/vid5.mp4</file>
    <name> 5 </name>
    </vid>

  <vid>
    <file>ASSETS/MOVIES/vid6.mp4</file>
    <name> 6 </name>
    </vid>

</videos>

任何帮助都会很棒!

0 个答案:

没有答案