简体   繁体   中英

Error 2124 Unknown Type

I am trying to read and parse an XML file but Builder constantly throws Error #2124: Loader file is an unknown type. Here is the code I do the action


<?xml version = "1.0" encoding = "utf-8"?>
<s:WindowedApplication xmlns:fx = "http://ns.adobe.com/mxml/2009"
                   xmlns:s = "library://ns.adobe.com/flex/spark"
                   xmlns:mx = "library://ns.adobe.com/flex/mx"
                   width = "1920" height = "1080"
                   preinitialize="Awake(event)"
                   applicationActivate="FS(event)"
                   x = "0" y = "0">
<fx:Script>
    <![CDATA[
        import flash.events.Event;
        import flash.display.Loader;
        import flash.net.URLLoader;
        import flash.net.URLRequest;
        import flash.errors.IOError;
        import flash.events.IOErrorEvent;
        import flash.events.ErrorEvent;

        private var tempStr:String;
        private var eventTitle:Array;
        private var data:XML = new XML();
        private var titleArray:Array;

        private function Awake(reference:Event):void
        {
            var str:String = "content.xml"
            Start(str);
        }

        private function FS(ref_fs:Event):void
        {
            stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
        }

        private function Start(address:String):void
        {
            var xmlLoader:Loader = new Loader;
            xmlLoader.addEventListener(ErrorEvent.ERROR, OpenError);
            xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, OpenError);
            xmlLoader.addEventListener(Event.COMPLETE, DoXML);
            xmlLoader.load(new URLRequest(address));
        }

        private function DoXML(ref_xml:Event):void
        {
            data = new XML(ref_xml.target.data);
            var rawData:String = data;
            titleArray = new Array;
            var size:int = 0;
            data = data.children()[1];
            size = data.children().length();
            for(var loop:uint = 0; loop < size; loop++)
            {
                titleArray[loop] = data..ICE[loop].BAS[0];
            }
            eventTitle = new Array;
            eventTitle = titleArray;
            Finalise(eventTitle);
        }

        private function Finalise(tempArray:Array):void
        {
            tempStr = String(tempArray[0]);
            bas.text = tempStr;
        }

        private function OpenError(ref_err:IOErrorEvent):void
        {
            trace(ref_err.text);
        }
    ]]>
</fx:Script>
<fx:Style source = "Player.css"/>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:SWFLoader id = "SwfPlayerContainer" x = "320" y = "180" width = "1280" height = "720"/>
<s:TextInput id="bas" x="507" y="128" enabled="false"/>

var xmlLoader:URLLoader = new URLLoader;

it should be the URLLoader. That's why it expects different file format and the file is XML .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM