请看代码:
先贴出控制台里产生的错误如下:
ypeError: Error #1010: 术语尚未定义,并且无任何属性。
at Dashboard/salesRPCResult()[E:\Project\Flex项目集\FlexGrocer\flex_src\Dashboard.mxml:25]
at Dashboard/__salesRPC_result()[E:\Project\Flex项目集\FlexGrocer\flex_src\Dashboard.mxml:58]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\mxml\HTTPService.as:290]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:193]
at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]
at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
发生错误的代码在第25行和第58行,这两处的代码我先贴出来:
private function salesRPCResult(event:ResultEvent):void{
sales.dp = event.result.salesData.dailySales;
}
<mx:HTTPService id="salesRPC"
url="http://localhost:8080/FlexGrocer/xml/rawSalesData.xml"
result="salesRPCResult(event)"
fault="showFault(event)"/>
再贴出所有的代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:v="views.dashboard.*"
layout="horizontal"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
[Bindable]
private var categories:ArrayCollection=new ArrayCollection();
private function catHandler(event:ResultEvent):void{
categories = event.result.catalog.category;
var catObj:Object = new Object();
catObj.name = "All";
catObj.categoryID = 0;
categories.addItemAt(catObj, 0);
catCombo.selectedIndex = 0;
}
private function salesRPCResult(event:ResultEvent):void{
sales.dp = event.result.salesData.dailySales;
}
private function typeRPCResult(event:ResultEvent):void{
type.dp = event.result.categorySalesData.categorySales;
}
private function compRPCResult(event:ResultEvent):void{
comp.dp = event.result.salesData.dailySales;
}
private function showFault(event:FaultEvent):void{
trace(event.fault.faultCode+":"+event.fault.faultString);
}
private function getData():void{
salesRPC.send();
typeRPC.send();
compRPC.send();
}
private function init():void{
startDate.selectedDate = new Date(2006,3,1);
endDate.selectedDate = new Date(2006,4,1);
catRPC.send();
getData();
}
]]>
</mx:Script>
<mx:HTTPService id="salesRPC"
url="http://localhost:8080/FlexGrocer/xml/rawSalesData.xml"
result="salesRPCResult(event)"
fault="showFault(event)"/>
<mx:HTTPService id="typeRPC"
url="http://localhost:8080/FlexGrocer/xml/categorySalesData.xml"
result="typeRPCResult(event)"
fault="showFault(event)"/>
<mx:HTTPService id="compRPC"
url="http://localhost:8080/FlexGrocer/xml/salesData.xml"
result="compRPCResult(event)"
fault="showFault(event)"/>
<mx:HTTPService id="catRPC"
url="http://localhost:8080/FlexGrocer/xml/category.xml"
result="catHandler(event)"/>
<mx:ApplicationControlBar dock="true">
<mx:Label text="Start Date"/>
<mx:DateField id="startDate"/>
<mx:Label text="End Date"/>
<mx:DateField id="endDate"/>
<mx:Spacer width="100%"/>
<mx:ComboBox id="catCombo"
dataProvider="{categories}"
labelField = "name"/>
<mx:Spacer width="100%"/>
<mx:RadioButtonGroup id="grossOrNetGroup"/>
<mx:RadioButton id="gross"
groupName="grossOrNetGroup"
label="Gross Sales"
data="GROSS"
selected="true"/>
<mx:RadioButton id="net"
groupName="grossOrNetGroup"
label="Net Sales"
data="NET"/>
</mx:ApplicationControlBar>
<mx:states>
<mx:State name="fullSales">
<mx:SetProperty target="{rightCharts}"
name="width" value="0"/>
<mx:SetProperty target="{rightCharts}"
name="height" value="0"/>
</mx:State>
<mx:State name="fullType">
<mx:SetProperty target="{sales}"
name="width"
value="0"/>
<mx:SetProperty target="{sales}"
name="height"
value="0"/>
<mx:SetProperty target="{comp}"
name="width"
value="0"/>
<mx:SetProperty target="{comp}"
name="height"
value="0"/>
</mx:State>
<mx:State name="fullComp">
<mx:SetProperty target="{sales}"
name="width"
value="0"/>
<mx:SetProperty target="{sales}"
name="height"
value="0"/>
<mx:SetProperty target="{type}"
name="width"
value="0"/>
<mx:SetProperty target="{type}"
name="height"
value="0"/>
</mx:State>
</mx:states>
<v:ChartPod id="sales"
width="100%" height="100%"
title="Sales Chart"
maximize="this.currentState='fullSales'"
restore="this.currentState=''">
</v:ChartPod>
<mx:VBox id="rightCharts"
width="100%" height="100%" >
<v:ChartPod id="type"
width="100%" height="100%"
title="Category Chart"
maximize="this.currentState='fullType'"
restore="this.currentState=''">
</v:ChartPod>
<v:ChartPod id="comp"
width="100%" height="100%"
title=" Comparison Chart"
maximize="this.currentState='fullComp'"
restore="this.currentState=''">
</v:ChartPod>
</mx:VBox>
</mx:Application>
上面所引入的xml文件都在工程目录下xml文件夹里有定义
其中salesData.xml文件的定义:
<?xml version="1.0" encoding="UTF-8"?>
<dailySales>
<CATEGORY>Dairly</CATEGORY>
<DISALES>10-Apr-06</DISALES>
<SUMECOST>5000</SUMECOST>
<SUMELIST>300</SUMELIST>
<CATEGORY>Gail</CATEGORY>
<DISALES>10-Apr-06</DISALES>
<SUMECOST>3000</SUMECOST>
<SUMELIST>200</SUMELIST>
<CATEGORY>Deary</CATEGORY>
<DISALES>10-Apr-06</DISALES>
<SUMECOST>6000</SUMECOST>
<SUMELIST>300</SUMELIST>
<CATEGORY>Sick</CATEGORY>
<DISALES>10-Apr-06</DISALES>
<SUMECOST>5500</SUMECOST>
<SUMELIST>300</SUMELIST>
<CATEGORY>Coll</CATEGORY>
<DISALES>10-Apr-16</DISALES>
<SUMECOST>5002</SUMECOST>
<SUMELIST>303</SUMELIST>
<CATEGORY>Bairly</CATEGORY>
<DISALES>10-Apr-06</DISALES>
<SUMECOST>10000</SUMECOST>
<SUMELIST>300</SUMELIST>
<CATEGORY>Eairly</CATEGORY>
<DISALES>10-Apr-06</DISALES>
<SUMECOST>50210</SUMECOST>
<SUMELIST>300</SUMELIST>
<CATEGORY>Devrly</CATEGORY>
<DISALES>03-Apr-26</DISALES>
<SUMECOST>5030</SUMECOST>
<SUMELIST>100</SUMELIST>
<CATEGORY>Everly</CATEGORY>
<DISALES>10-Jun-06</DISALES>
<SUMECOST>5020</SUMECOST>
<SUMELIST>90</SUMELIST>
<CATEGORY>Biirly</CATEGORY>
<DISALES>03-Oct-06</DISALES>
<SUMECOST>5000</SUMECOST>
<SUMELIST>30</SUMELIST>
<CATEGORY>Weill</CATEGORY>
<DISALES>10-Sept-06</DISALES>
<SUMECOST>45000</SUMECOST>
<SUMELIST>300</SUMELIST>
<CATEGORY>Billly</CATEGORY>
<DISALES>03-Apr-06</DISALES>
<SUMECOST>5000</SUMECOST>
<SUMELIST>300</SUMELIST>
</dailySales>
搞不清楚为什么还会出现这种属性未定义的错误,跪求大虾指点啊,先散20分,多谢了!