Flex 3 : UIComponent.addChild issue
- by Frank
Hello SOers, I've run into a nice problem with the UIComponent.addChild(...) function.
First of all, I'm using ESRI Api for Flex. In this API you find a class called Graphic that inherits UIComponent. Basically, I'm trying to add, as a child, a Graphic 'g' to another graphic 'parent'. So that when you delete the 'parent' graphic the 'g' graphic deletes as well.
private function writeMeasurements(parent:Graphic):void
{
var g:Graphic;
if(parent.geometry.extent != null)
g = new Graphic(parent.geometry.extent.center);
else
g = new Graphic(parent.geometry);
g.initialize();
g.name = UIDUtil.createUID();
g.symbol = txtSym;
graphicsLayer.add(g);
parent.addChild(g);
}
graphicsLayer class
This code actually runs pretty fine. The problem is after... it's like if the addChild function was asynchronious.
This is the error I get :
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
at com.esri.ags::Graphic/updateDisplayList()[C:\checkout\flex_api\api\src\com\esri\ags\Graphic.as:346]
at mx.core::UIComponent/validateDisplayList()
at mx.managers::LayoutManager/validateDisplayList()
at mx.managers::LayoutManager/doPhasedInstantiation()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()
at mx.core::UIComponent/callLaterDispatcher()
I know this is a very specific question, but I think you guys are the BEST!
Thanks.