2015-09-09 98 views
-1

我想讀和解析XML文件,但生成器不斷拋出Error #2124: Loader file is an unknown type.這是我做的動作錯誤2124未知類型


<?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"/> 

回答

0
var xmlLoader:URLLoader = new URLLoader; 

應該是代碼URLLoader。這就是爲什麼它期望不同的文件格式和文件是XML