Thanks for your reply Alex, Are you refering to an init function that is built into the base flex component (ie canvas in this case), because IDSWeather has a custom init() function defined. In this function I use createComponentsFromDescriptors(); with a creation policy set to NONE.
Since my post i have fiddled around with the code and it doesn't crash but my component is empty! It seems that my component has a problem displaying it's subcomponents. Basically now my IDSWeather component gets added to the stage but it's empty (i know this because we have 'handles' around the components that allow us to resize them and those are visible). After a given amount of time it changes to another state in which an image is added again. When the component wants to switch to this state it crashes again with the error i mentionned before. So i would say that the component get's added to the stage but as soon as an image is added to it, it crashes. Having said this the component doesn't seem to have rendered any of it's subcomponents so the problem might be there. It is really not an easy problem to explain :-) Might i be able to send you some source files directly? Thanks for your help, I've been stuck on this for 2 days and i just can't get my head around it. Best Regards, Anthony. --- In [email protected], Alex Harui <aha...@...> wrote: > > Maybe IDSWeather::init() is being called before IDSWeather has been added as > a child to a container. > > Alex Harui > Flex SDK Developer > Adobe Systems Inc.<http://www.adobe.com/> > Blog: http://blogs.adobe.com/aharui > > From: [email protected] [mailto:[email protected]] On > Behalf Of gordofeatherfoot > Sent: Monday, July 13, 2009 8:52 AM > To: [email protected] > Subject: [flexcoders] Issue adding an Image component to a custom component > > > > > > Hello, > > I have a problem that is not so easy to expose so please bare with me. > > I have a Component class written is AS3 which extends the Canvas Class. I > then have a weather component written in mxml that uses as a base the the > Component class. ie my weather component.mxml looks something like this: > > <components:Component > xmlns:components="net.zzzzzz.components.*" > xmlns:mx="http://www.adobe.com/2006/mxml" > verticalScrollPolicy="off" horizontalScrollPolicy="off" > preinitialize="onPreInitialize()"> > ... > ... > <script .........> > <mx:HBox id="hbxBackground" width="256" height="120" /> > > <mx:HBox id="hbxInnerFrame" x="15" y="15" width="226" height="50"/> > > <mx:HBox id="hbxBottom" x="15" y="65" width="226" height="40"/> > > <mx:HBox id="hbxMiddle" x="15" y="40" width="226" height="40"/> > > <mx:Label id="lblLocation" x="15" y="12" width="226"/> > > <mx:Image id="meteoImg" x="56" y="63" /> -----> this causes the error ! > > <mx:Label id="lblTemperature" x="132" y="40" width="100"/> > > <mx:Label id="lblDayTitle" x="15" y="78" width="226"/> > </components:Component> > > This weather component is compiled into a swf seperatly from my main app. > In my main app I load the weather component definition from the swf with a > loader. I instantiate this weather component (by extracting it's definition > through the loader) and add it to the stage. > > When adding it to the stage i get the following error: > > TypeError: Error #1009: Cannot access a property or method of a null object > reference. > at > mx.controls::SWFLoader/addedToStageHandler()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\controls\SWFLoader.as:1990] > at flash.display::DisplayObjectContainer/addChildAt() > at > mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::$addChildAt()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5083] > at > mx.core::Container/addChildAt()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\Container.as:2215] > at > mx.core::Container/addChild()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\Container.as:2140] > at > mx.core::Container/createComponentFromDescriptor()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\Container.as:3681] > at > mx.core::Container/createComponentsFromDescriptors()[C:\autobuild\3.3.0\frameworks\projects\framework\src\mx\core\Container.as:3493] > at > IDSWeather/init()[/Users/bounce/Documents/IdScreen/Components/src/IDSWeather.mxml:375] > > This error happens when flex is trying to add the Image component that i > defined in the mxml of the weather component. Specifically this error happens > in SWFLoader in the following function: > > private function addedToStageHandler(event:Event):void > { > systemManager.getSandboxRoot().addEventListener(InterManagerRequest.DRAG_MANAGER_REQUEST, > mouseShieldHandler, false, 0, true); > } > > Here 'systemManager' is null and i don't understand why. > > Any help would be very much appreaciated. > > Many thanks, > Bounce. >

