在下面的代码中,我无法理解为什么我收到此错误:无法明确解析多个名称的引用。 spark.components:标签它之前工作,现在我只是得到错误信息。
<?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>
答案 0 :(得分:4)
您将spark.components.Label与mx.controls.Label混为一谈。 AS代码中的Label是一个mx(请参阅import语句),但mxml代码中的Label是Spark版本(请参阅's'命名空间)。
它们实际上是一种 - 相同的 - 组件;前者是Flex 4的后者,后者是Flex 3组件
由于您似乎正在构建Flex 4应用程序,因此请坚持使用Spark版本。只需用spark classpath替换mx'import'语句:
import spark.components.Label