I'm not sure I see where arrayStep is defined in parentDocument.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of freska
Sent: Monday, September 03, 2007 10:18 PM
To: [email protected]
Subject: [flexcoders] passing reference?



Hi list,
Please review my code. I have no better words to explain my problem.

In the main file, I have this variable.

[Bindable]
public var arrayStep:ArrayCollection = new ArrayCollection();

In my component file, I define a DataGrid component using three
ComboBox as item editor. I need to pass that variable to one of them.
Here is the code. I mark the part with a comment.

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " width="480"
height="336">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

// array untuk menyimpan data result (tabel)
[Bindable]
public var arrayStepResChild:ArrayCollection = new ArrayCollection();

/* This is not correct. */
[Bindable]
public var myArrayStep:ArrayCollection =
parentDocument.arrayStep;

]]>
</mx:Script>

<mx:Component id="goToEditor">
<mx:ComboBox dataProvider="{outerDocument.myArrayStep}"
labelField="colLabel"/>
</mx:Component>

<mx:Component id="timeEditor">
<mx:ComboBox dataProvider="{arrayTime}" labelField="time">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var arrayTime:ArrayCollection = new
ArrayCollection([{time:"immediately"}, {time:"1 hour"}, {time:"1
day"}, {time:"1 week"}]);
]]>
</mx:Script> 
</mx:ComboBox>
</mx:Component>

<mx:Component id="roleEditor">
<mx:ComboBox dataProvider="{arrayRole}" labelField="role">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var arrayRole:ArrayCollection = new
ArrayCollection([{role:"Employee"}, {role:"Manager"}, {role:"HR
Admin"}, {role:"Finance"}]);
]]>
</mx:Script> 
</mx:ComboBox>
</mx:Component>

<mx:Canvas width="100%" height="100%" minHeight="256">
<mx:Button id="btnAddStepResult" x="20" y="10" label="New"
click="addStepResult()"/>
<mx:Button id="btnSaveStepResult" x="78" y="10" label="Save"/>
<mx:Button id="btnRemoveStepResult" x="140" y="10" label="Delete"
click="removeStepResult()"/>

<mx:DataGrid id="dataGridResult" x="20" y="40" width="428"
height="110" sortableColumns="false" 
dataProvider="{arrayStepResChild}" editable="true"
draggableColumns="false">
<mx:columns>
<mx:DataGridColumn headerText="Result" dataField="colResult"/>
<mx:DataGridColumn headerText="Go to" dataField="colGoTo"
itemEditor="{goToEditor}"/>
<mx:DataGridColumn headerText="Time" dataField="colTime"
itemEditor="{timeEditor}"/>
<mx:DataGridColumn headerText="Assigned to" dataField="colRole"
itemEditor="{roleEditor}"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>

</mx:HBox>

Flex said, "Error #1009: Cannot access a property or method of a null
object reference." I've tried to fill the arrayStep with initial
value, but it also throws the same error message. Please give me a
clue on this.

TIA,
Freska



 

Reply via email to