2 Replies Latest reply on Jun 5, 2010 3:48 AM by Maxijin2

    Flex 4 : Template Component : STATES : Null Problem

    Maxijin2 Level 1

      Hi

      I have created a template component based on following link

      http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-79c3.html

       

      My component uses STATES, and and my code assign a runtime new component in second state. When i run code, i get "Cannot access a property or method of a null object reference." Error.

       

      Please Help

       

       

      Main File Code

           <local:TemplateComp>
                <local:Edit>
                     <s:RichEditableText/>
                </local:Edit>
           </local:TemplateComp>
      

      Template component Code

      <?xml version="1.0" encoding="utf-8"?>
      <s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark" 
                 xmlns:mx="library://ns.adobe.com/flex/mx"
                 verticalAlign="middle" horizontalAlign="center"
                 width="400" height="300" initialize="vgroup1_initializeHandler(event)"> 
           
           <s:states>
                <s:State name="State1"/>
                <s:State name="SECOND"/>
           </s:states>
      
           <fx:Script>
                <![CDATA[
                     import mx.core.UIComponent;
                     import mx.events.FlexEvent;               
                     public var Edit:UIComponent;
      
                     protected function vgroup1_initializeHandler(event:FlexEvent):void
                     {
                          BaseArea.addElement(Edit);
                     }
      
                ]]>
           </fx:Script>
           
           <s:Label text="First View" includeIn="State1"/>
           <s:VGroup id="BaseArea" includeIn="SECOND" width="200" height="200"/>
      </s:VGroup>