为什么不能访问空对象引用的属性或方法。
TypeError:错误 #1009:无法访问空对象引用的属性或方法。在 barm/btn1_clickHandler()[C:\Users\Android\Adobe Flash Builder 4.6\barm\src\barm.mxml:32] 在 barm/__btn1_click()[C:\Users\Android\Adobe Flash Builder 4.6\barm\ src\barm.mxml:65]
<?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"
xmlns:service="services.service.*"
>
<fx:Script>
<![CDATA[
import com.adobe.serializers.utility.TypeUtility;
import flash.sampler.DeleteObjectSample;
import flashx.textLayout.operations.DeleteTextOperation;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.FlexEvent;
import spark.events.IndexChangeEvent;
[Bindable]
private var positionChoose:ArrayCollection = new ArrayCollection();
protected function btn1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
GetStrDataResult.token = service.GetStrData(
"SELECT PositionCode,LocalDesc FROM StaffPosition
WHERE LocalDesc IN ('พนักงานขาย','Administrator','Trainner')","StaffPosition");
var POS:Object ;
POS= GetStrDataResult.lastResult;
var savePosition:Array = new Array(POS.toString().split('|').length);
var savePositionID:Array = new Array(POS.toString().split('|').length);
var savePositionName:Array = new Array(POS.toString().split('|').length);
var index:int;
savePosition = POS.toString().split('|');
for( index = 0; index < savePositionID.length; index++ )
{
savePositionID[index] = savePosition[index].split('^')[0];
}
for( index = 0; index < savePositionName.length; index++ )
{
savePositionName[index] = savePosition[index].split('^')[1];
positionChoose.addItem(savePositionName[index]);
}
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="GetStrDataResult"/>
<service:Service id="service"
fault="Alert.show(event.fault.faultString + '\n'+event.fault.faultDetail)"
showBusyCursor="true"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:DropDownList id="dropDownList" x="39" y="31" width="164"
dataProvider="{positionChoose}"></s:DropDownList>
<s:Button id="btn1" x="132" y="64" label="Button"
click="btn1_clickHandler(event)"/>
</s:WindowedApplication>
null 是 POS。如何 POS 不为 null。
var POS:Object;
POS = GetStrDataResult.lastResult;
var savePosition:Array = new Array(POS.toString().split('|').length);