PDA

View Full Version : Code Initializing in MXML; Throwing Type Error 1009 in AS3


phirstube
08-13-2008, 03:36 PM
When I create my PlanTree in MXML it works fine but when I try to initialize it in ActionScript I get Type Error: 1009 when .addChild gets called to place the PlanTree in the parent container. Any suggestions on what I am doing wrong?

Here is the code:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:me="mil.af.oeavt.app.*" xmlns:tree="mx.controls.treeClasses.*" creationComplete="gInit()">

<mx:Script source="/../../../../includes/PlanTree.as"/>

<mx:VBox label="Assessment" height="100%" verticalGap="1" paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0" borderStyle="solid" borderThickness="1" backgroundColor="0xE6E6F2">
<mx:Label text="Assessment Explorer" fontSize="16" fontWeight="bold"/>
<mx:ViewStack id="explorerTn" backgroundColor="0xE6E6F2" borderThickness="0">
<mx:VBox label="Assessment" height="100%" paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5" backgroundColor="0xE6E6F2">
<me:InfAssessTree id="myTree" width="280" height="610" labelField="@label" maxHeight="680" showDataTips="true" dataTipFunction="dtfunc"
verticalScrollPolicy="on" horizontalScrollPolicy="on" useRollOver="false" selectionColor="0xE0E0F2"
showRoot="false" dataProvider="{gTreeData}" openItems="{gTreeData..node}" change="treeChanged(event)" >
<me:dataDescriptor>
<me:InfAssesTreeDataDescriptor/>
</me:dataDescriptor>
<me:itemRenderer>
<mx:Component>
<tree:TreeItemRenderer toolTipShow="outerDocument.startTip()" toolTipShown="outerDocument.reposToolTip()"
mouseMove="outerDocument.reposToolTip()" toolTipHide="outerDocument.endTip()" toolTipEnd="outerDocument.endTip()"/>
</mx:Component>
</me:itemRenderer>
</me:InfAssessTree>
</mx:VBox>
<mx:VBox label="Global Review" height="100%" paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5" backgroundColor="0xE6E6F2">
<mx:VBox height="610" width="259" horizontalScrollPolicy="on" borderStyle="solid" borderThickness="1" backgroundColor="0xFFFFFF">
<mx:Spacer height="2"/>
<me:InfAssessTreeGlobal id="gTree" width="160" height="5000" showDataTips="true" dataTipFunction="dtfunc" maxHeight="700" borderThickness="0"
verticalScrollPolicy="off" horizontalScrollPolicy="off" useRollOver="true" selectionColor="0xE0E0F2" rollOverColor="0xFFFFFF"
rowHeight="4" openItems="{gTreeData..node}" labelFunction="tree_labelFunc" indentation="16"
folderOpenIcon="mil.af.oeavt.app.AssessIcon" folderClosedIcon="mil.af.oeavt.app.AssessIcon" defaultLeafIcon="mil.af.oeavt.app.AssessIcon"
showRoot="false" dataProvider="{gTreeData.node}" dataDescriptor="{new InfAssesTreeDataDescriptorGlobal()}" change="gTreeChanged(event)" styleName="gTree"
itemRollOver="itemRollOver(event)" itemRollOut="itemRollOut(event)" >
<me:itemRenderer>
<mx:Component>
<tree:TreeItemRenderer toolTipCreate="outerDocument.createAssStatTip(event)" toolTipShow="outerDocument.startTip()" toolTipShown="outerDocument.reposToolTip()"
mouseMove="outerDocument.reposToolTip()" toolTipHide="outerDocument.endTip()" toolTipEnd="outerDocument.endTip()"/>
</mx:Component>
</me:itemRenderer>
</me:InfAssessTreeGlobal>
<mx:Spacer height="10"/>
</mx:VBox>
</mx:VBox>
</mx:ViewStack>
<mx:HBox horizontalAlign="right" height="22">
<mx:Spacer width="110"/>

</mx:HBox>
<mx:Spacer height="5"/>
</mx:VBox>

</mx:Application>

phirstube
08-13-2008, 04:03 PM
Notice how in the <mx:Application> tag above creationComplete="gInit()"

Just put a stop in the code and gInit() is never getting called. I think this is the root of my problem.

Sly_cardinal
08-16-2008, 01:50 PM
The 1009 error is a null pointer exception - that means that you are trying to access functions or properties of an object before it has been initialised.

The error will give you the line number where this is ocurring so you can track down the problem.

If you still need a hand then you'll probably need to include the PlanTree.as class and the line number where the error is ocurring.