2014-01-10 32 views
2

在下面的代碼中,我無法弄清楚爲什麼我得到這個錯誤:無法明確地解析多重引用。 spark.components:標籤它以前工作,現在我只是得到錯誤消息。Spark Label Unamiguious問題

<?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="800" height="523" maxWidth="800" maxHeight="523" initialize="httpService.send()" showStatusBar="false" backgroundColor="white" backgroundAlpha="1"> 
    <fx:Script> 
     <![CDATA[ 
      import mx.collections.ArrayCollection; 
      import mx.controls.Label; 
      import mx.rpc.events.ResultEvent; 

      public var returnData:ArrayCollection; 

      protected function httpService_handler(event:ResultEvent):void{ 
       returnData = event.result.people.person; 

       for(var i:int = 0; i < 5; i++){ 

        var lbl:Label = new Label(); 
        lbl.text = "News Item " + i; 
        //newsHGroup.addElement(lbl); 
       } 
      } 
     ]]> 
    </fx:Script> 
    <fx:Style> 
     @namespace s "library://ns.adobe.com/flex/spark"; 
     @namespace mx "library://ns.adobe.com/flex/mx"; 


    </fx:Style> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
     <s:HTTPService id="httpService" url="http://pipingautos.com/~nibbrco/glen-dev-folder/air/school-catch-up/test.php" result="httpService_handler(event)" /> 
    </fx:Declarations> 

    <s:BorderContainer borderVisible="false" mouseDown="nativeWindow.startMove();" skinClass="MainStyle" width="800" height="523" id="container"> 
     <s:Group id="newsSlider" left="435" top="120" height="100" width="340"> 
      <s:Rect width="100%" height="100%" id="backRect"> 
       <s:fill><s:SolidColor color="0xc7d1e5" alpha="0.5" /></s:fill> 
      </s:Rect> 
      <s:HGroup> 
       <s:Label text="testing" /> 
      </s:HGroup> 
     </s:Group> 

    </s:BorderContainer> 
</s:WindowedApplication> 

回答

4

你混淆spark.components.Labelmx.controls.Label。 AS代碼中的標籤是mx(請參閱import語句),但mxml代碼中的Label是Spark版本(請參閱's'名稱空間)。
他們實際上是一樣的 - 相同的組件;前者是後者的Flex 4等效物,後者是Flex 3組件。
由於您似乎在構建Flex 4應用程序,只需使用Spark版本即可。只是火花類路徑替換MX「進口」語句:

import spark.components.Label 
+0

請注意,如果你想顯示的人員名單,你最好使用列表或DATAGROUP而不是「人工」添加標籤。 – RIAstar