Flash AS3 text =错误#2124:导入XML时,加载文件是未知类型?

时间:2013-05-29 18:46:04

标签: xml actionscript-3 flash

我似乎无法在任何符合我需要的地方找到一个帖子,所以如果在其他地方已经回答,请指导我。

目前正在将我的头发拉出一个不应该发生的错误。我正在制作一个flash网站,其中包含一个XML库,就像我之前在很多很多项目中所做的那样(like this one)。但是,当我加载XML文件时,出现以下错误:

Error #2044: Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type.

这个项目与以前的项目唯一不同的是我在文档类编码中完成所有这些,但到目前为止,这根本不是问题。我真的很困惑为什么flash不喜欢XML文件,我认为还有其他东西会出现这个错误,或者我没有导入一些东西而不是Flash,而不是识别文件类型。

以下是相关代码:

    public function pg3_setup():void
    {
        trace("Page 3 setup in progress...");
        p3_gallery_loader.load(new URLRequest("flash_scripts/gallery.xml"));
        p3_gallery_loader.addEventListener(Event.COMPLETE,process_gallery);

        function process_gallery(e:Event):void
        {
            trace("Gallery loaded");
            var gallery_xml:XML = new XML(e.target.data);
            image_list = gallery_xml.IMAGE;
            number_of_images = image_list.length();
            container_mask_width = bg.width - p_pad_left - p_pad_right;
            create_container();
            load_thumbs();
        }
    }

我从未进入process_gallery函数,因此永远不会跟踪“Gallery loaded”。对此(可能非常明显)问题的任何帮助都会很棒!

更新:应该也可能包含有问题的XML,尽管据我所知,它与我用于此类事物的所有其他XML文件相同。

<?xml version="1.0" encoding="utf-8"?>
<GALLERY ROWS="1" WIDTH="25" HEIGHT="25">
<IMAGE FULL="full_images/I01.jpg" THUMB="thumbs/TI01.jpg" DES="PICTURE_1"/>
<IMAGE FULL="full_images/I02.jpg" THUMB="thumbs/TI02.jpg" DES="PICTURE_2"/>
<IMAGE FULL="full_images/I03.jpg" THUMB="thumbs/TI03.jpg" DES="PICTURE_3"/>
<IMAGE FULL="full_images/I04.jpg" THUMB="thumbs/TI04.jpg" DES="PICTURE_4"/>
<IMAGE FULL="full_images/I05.jpg" THUMB="thumbs/TI05.jpg" DES="PICTURE_5"/>
<IMAGE FULL="full_images/I06.jpg" THUMB="thumbs/TI06.jpg" DES="PICTURE_6"/>
<IMAGE FULL="full_images/I07.jpg" THUMB="thumbs/TI07.jpg" DES="PICTURE_7"/>
<IMAGE FULL="full_images/I08.jpg" THUMB="thumbs/TI08.jpg" DES="PICTURE_8"/>
<IMAGE FULL="full_images/I09.jpg" THUMB="thumbs/TI09.jpg" DES="PICTURE_9"/>
<IMAGE FULL="full_images/I10.jpg" THUMB="thumbs/TI10.jpg" DES="PICTURE_10"/>
<IMAGE FULL="full_images/I11.jpg" THUMB="thumbs/TI11.jpg" DES="PICTURE_11"/>
<IMAGE FULL="full_images/I12.jpg" THUMB="thumbs/TI12.jpg" DES="PICTURE_12"/>
<IMAGE FULL="full_images/I13.jpg" THUMB="thumbs/TI13.jpg" DES="PICTURE_13"/>
<IMAGE FULL="full_images/I14.jpg" THUMB="thumbs/TI14.jpg" DES="PICTURE_14"/>
<IMAGE FULL="full_images/I15.jpg" THUMB="thumbs/TI15.jpg" DES="PICTURE_15"/>
<IMAGE FULL="full_images/I16.jpg" THUMB="thumbs/TI16.jpg" DES="PICTURE_16"/>
<IMAGE FULL="full_images/I17.jpg" THUMB="thumbs/TI17.jpg" DES="PICTURE_17"/>
<IMAGE FULL="full_images/I18.jpg" THUMB="thumbs/TI18.jpg" DES="PICTURE_18"/>
<IMAGE FULL="full_images/I19.jpg" THUMB="thumbs/TI19.jpg" DES="PICTURE_19"/>
<IMAGE FULL="full_images/I20.jpg" THUMB="thumbs/TI20.jpg" DES="PICTURE_20"/>
<IMAGE FULL="full_images/I21.jpg" THUMB="thumbs/TI21.jpg" DES="PICTURE_21"/>
<IMAGE FULL="full_images/I22.jpg" THUMB="thumbs/TI22.jpg" DES="PICTURE_22"/>
<IMAGE FULL="full_images/I23.jpg" THUMB="thumbs/TI23.jpg" DES="PICTURE_23"/>
<IMAGE FULL="full_images/I24.jpg" THUMB="thumbs/TI24.jpg" DES="PICTURE_24"/>
<IMAGE FULL="full_images/I25.jpg" THUMB="thumbs/TI25.jpg" DES="PICTURE_25"/>
<IMAGE FULL="full_images/I26.jpg" THUMB="thumbs/TI26.jpg" DES="PICTURE_26"/>
<IMAGE FULL="full_images/I27.jpg" THUMB="thumbs/TI27.jpg" DES="PICTURE_27"/>
<IMAGE FULL="full_images/I28.jpg" THUMB="thumbs/TI28.jpg" DES="PICTURE_28"/>
<IMAGE FULL="full_images/I29.jpg" THUMB="thumbs/TI29.jpg" DES="PICTURE_29"/>
<IMAGE FULL="full_images/I30.jpg" THUMB="thumbs/TI30.jpg" DES="PICTURE_30"/>
<IMAGE FULL="full_images/I31.jpg" THUMB="thumbs/TI31.jpg" DES="PICTURE_31"/>
<IMAGE FULL="full_images/I32.jpg" THUMB="thumbs/TI32.jpg" DES="PICTURE_32"/>
</GALLERY>

2 个答案:

答案 0 :(得分:6)

如果没有看到整个代码,我无法确定,但我的猜测是 p3_gallery_loader对象是Loader类,它应该是URLLoader类。< / p>

此外,最好在调用load方法之前添加事件侦听器。在连接监听器之前,完整的事件可能会触发。

还有一点需要注意:为避免收到Unhandled IOErrorEvent错误,您应该添加一个事件侦听器来处理此错误。否则,如果用户碰巧安装了Flash调试播放器,用户将获得一个丑陋的弹出窗口。

更新了代码块:

p3_gallery_loader.addEventListener(IOErrorEvent.IO_ERROR, onError);
p3_gallery_loader.addEventListener(Event.COMPLETE,process_gallery);
p3_gallery_loader.load(new URLRequest("flash_scripts/gallery.xml"));

答案 1 :(得分:0)

我是大量的白痴。意外地将加载器(p3_gallery_loader)作为加载器变量而不是URLLoader。一切都很好。我真的希望没有人能看到这一点。