8 Replies Latest reply on Feb 11, 2011 5:13 AM by bspShankar

    Accessing containers within viewstack

    bspShankar Level 1

      Hi,

      I have problem when changing the selected child of datagrid....

      I am getting error

       

               TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at traverseTest/button1_clickHandler()[C:\Documents and Settings\xp\Adobe Flash Builder 4 Plug-in\traverseTest\src\traverseTest.mxml:11]
          at traverseTest/___traverseTest_Button1_click()[C:\Documents and Settings\xp\Adobe Flash Builder 4 Plug-in\traverseTest\src\traverseTest.mxml:22]

       

       

       

      Code..............


      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                             xmlns:s="library://ns.adobe.com/flex/spark"
                             xmlns:mx="library://ns.adobe.com/flex/mx">
          <fx:Script>
              <![CDATA[
                  import mx.events.ListEvent;
                  protected function button1_clickHandler(event:MouseEvent):void
                  {
                      VS.selectedChild = html;
                      reader.location = "hello"; //I am  getting error here
                  }

       

              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <mx:ViewStack id="VS">
              <mx:Canvas id="datagrid">
                  <s:Label text="Hi"/>
                  <s:Button click="button1_clickHandler(event)"/>
              </mx:Canvas>
              <mx:Canvas id="html">
                  <mx:HTML id="reader">
                     
                  </mx:HTML>
              </mx:Canvas>
          </mx:ViewStack>
         
      </s:WindowedApplication>

       

       

      Pls let me know why i am getting error

       

      Thanks & Regards

        • 1. Re: Accessing containers within viewstack
          Pablo Souza Level 3

          Hi,

           

          The reader component is not created yet when you are trying to have access to it.

          Set the creationPolicy all in order to solve this issue:

           

          <mx:ViewStack id="VS" creationPolicy="all">

           

           

          Greets,

          Pablo Souza

          • 2. Re: Accessing containers within viewstack
            bspShankar Level 1

            Thank u....it got solved

             

            But i do have problem with my html component


            i.e when ever pdf is displayed within html component

             

            it overlaps the menubar drop down menu

             

            i.e drop down comes behind pdf within html component...

             

            I posted the same issue many times but did not find any hint..

             

            Can u pls provide me an hint ...

             

            I tried with z-index and includein layout but it did not work

             

             

            Thanks & Regards

            • 3. Re: Accessing containers within viewstack
              Pablo Souza Level 3

              Where are you defining this drop down, which is its container ?

               

              Greets,

              Pablo Souza

              • 4. Re: Accessing containers within viewstack
                bspShankar Level 1

                Thanks for ur reply....

                 

                 

                    <s:VGroup id="vbox3" gap="0" paddingLeft="10" paddingTop="10" 
                              y="0" includeIn="References" width="1024" x="0" height="600">
                        <s:HGroup width="1003" height="45" gap="3">
                            <mx:Image id="bareacts" width="98" minHeight="10" click="this.createMenu('bareacts',BareActsXMLTag)" buttonMode="true"
                                      maxHeight="350" maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.bareActsImgCls}" left="0"/>
                           
                            <mx:Image id="commission" width="98" minHeight="10" click='Alert.show("Data under process","No Data")' buttonMode="true"
                                      maxHeight="350" maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.commisionImgCls}" left="0"/>
                           
                            <mx:Image id="judgements" width="98" minHeight="10" click="this.createMenu('judgements',JudgementsXMLTag)" buttonMode="true"
                                      maxHeight="350" maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.JudgementsImgCls}" left="0"/>
                           
                            <mx:Image id="authorities" width="98" minHeight="10" click="this.createMenu('authorities',AuthoritiesXMLTag)" buttonMode="true"
                                      maxHeight="350"  maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.authoritiesImgCls}" left="0"/>
                           
                            <mx:Image id="internationalImg" width="98" minHeight="10" source="{skins.ImageCls.ReferenceImgWrapper.internationalImgCls}"
                                      click="currentState = 'InternationalLaw';" buttonMode="true"  maxHeight="350"  maxWidth="250" height="41"/>
                           
                            <mx:Image id="bills" width="98" minHeight="10" click="this.createMenu('bills',BillsXMLTag)" buttonMode="true"
                                      maxHeight="350"  maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.billImgCls}" left="0"/>
                           
                            <mx:Image id="ordinance" width="98" minHeight="10" click="this.createMenu('ordinance',OrdinancesXMLTag)" buttonMode="true"
                                      maxHeight="350"  maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.ordinanceImgCls}" left="0"/>
                           
                            <mx:Image id="notifications" width="98" minHeight="10" click="this.createMenu('notifications',NotificationsXMLTag)" buttonMode="true"
                                      maxHeight="350"  maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.notificationImgCls}" left="0"/>
                           
                            <mx:Image id="personalLaw" width="98" minHeight="10" click='Alert.show("Data under process","No Data")' buttonMode="true"
                                      maxHeight="350" maxWidth="250" height="41" source="{skins.ImageCls.ReferenceImgWrapper.personalImgCls}" left="0"/>

                 

                        </s:HGroup>
                       
                        <mx:Canvas width="1003" height="45">
                            <mx:HBox>
                                <s:Button label="Back to search results" id="RefBackBtn" click="RefBackBtn_clickHandler(event)" visible="false"/>
                            </mx:HBox>
                            <s:BorderContainer backgroundImage="{skins.ImageCls.refImgWrapper.ReferencesSearchBorderImgCls}" borderVisible="false"
                                               x="303" y="0" height="40" width="700">
                                <s:Group width="158" x="191" y="3" height="35">
                                    <s:RadioButton id="IPC" label="IPC" x="4" y="5"/>
                                    <s:RadioButton id="CRPC" label="CRPC" x="50" y="5"/>
                                    <s:RadioButton id="CPC" label="CPC" x="107" y="5"/>
                                </s:Group>
                                <s:Group x="43" y="3" height="35" width="149">
                                    <s:RadioButton id="actsRB" label="Acts" x="7" y="5"/>
                                    <s:RadioButton id="judgementsRB" label="Judgements" x="55" y="5"/>
                                </s:Group>
                                <s:TextInput id="searchTxt" x="352" y="7" width="266" height="25" enter="searchButtonClick()"/>
                                <mx:Image id="searchBtn" buttonMode="true" click="searchButtonClick()"
                                          source="@Embed(source='/assets/images/componentImages/Search_btn.swf')" x="620" y="6"/>
                            </s:BorderContainer>
                        </mx:Canvas>
                        <mx:ViewStack id="vS" height="412" width="1002" creationPolicy="all">
                           <mx:Canvas id="rTE" width="100%" height="100%" borderStyle="solid" borderVisible="true" borderColor="#000000">
                            
                   <mx:HTML id="reader" width="100%" height="410" y="0" locationChange="reader_locationChangeHandler(event)"
                                         htmlRender="reader_htmlRenderHandler(event)" verticalScrollBarStyleName="customScroll">
                                </mx:HTML>
                            </mx:Canvas>

                           
                            <mx:Canvas id="datagrid" width="100%" height="100%">
                                <mx:VBox width="100%" height="100%" paddingBottom="5" paddingLeft="1" paddingRight="0"
                                         paddingTop="10" verticalScrollPolicy="off" horizontalScrollPolicy="off">
                                    <mx:DataGrid id="referenceDG" itemClick="openFile(event)" verticalScrollBarStyleName="customScroll"
                                                 width="100%" height="100%" showHeaders="false"
                                                 alternatingItemColors="[#ffffff,#ffffff]">
                                        <mx:columns>
                                            <!-- Inorder to only Display the File Name we used Label Function -->
                                            <mx:DataGridColumn dataField="*" fontWeight="normal" labelFunction="SplitFunc" 
                                                               direction="ltr" fontGridFitType="pixel" color="#000000"
                                                               fontSize="12" fontStyle="normal" fontFamily="Verdana"
                                                               wordWrap="true" resizable="false" width="14"/>
                                        </mx:columns>
                                       
                                    </mx:DataGrid>
                                    <mx:HRule width="968"/>
                                    <mx:HBox horizontalAlign="right" width="968">
                                        <mx:Button id="prevLabel" label="Prev" fontWeight="bold" enabled="{counter>1}" click="prv_clickHandler(event)" />
                                        <mx:Button id="nextLabel" label="Next" fontWeight="bold" click="nxt_clickHandler(event)" />
                                    </mx:HBox>
                                </mx:VBox>
                            </mx:Canvas>
                        </mx:ViewStack>
                    </s:VGroup>

                 

                 

                 

                ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ----------------------

                 

                private function createMenu(btnName:String,xmlTag:XML):void {
                            reader.htmlText="";
                            menu = new ScrollableArrowMenu();
                            menu = ScrollableArrowMenu.createMenu(null,xmlTag, false);
                            menu.labelField="@label";
                            menu.verticalScrollPolicy =  ScrollPolicy.OFF;
                            menu.arrowScrollPolicy =  ScrollPolicy.AUTO;
                            menu.maxHeight=350;
                            menu.maxWidth=250;
                            var pt:Point = new Point(0, 40);
                            menu.addEventListener(MenuEvent.ITEM_CLICK,BareActsMenuBar_itemClickHandler);
                             pt = bareacts.localToGlobal(pt);
                            }

                 

                 

                please help me out.....

                 

                Thanks & Regards

                • 5. Re: Accessing containers within viewstack
                  bspShankar Level 1

                  I am using ScrollableMenu.......

                   

                   

                  in order to override static function createMenu so that we create a
                           ScrollableMenu instead of a normal Menu.

                   

                   

                  Thanks & Regards

                  • 6. Re: Accessing containers within viewstack
                    Pablo Souza Level 3

                    I can't see which is the container that the menu is added to. But if you are using canvas you need to position its children in order to avoid this kind of issue.

                    Sometimes we need to set a Canvas mask to set the boundaries.

                     

                    Greets,

                    Pablo Souza

                    • 7. Re: Accessing containers within viewstack
                      bspShankar Level 1

                      Hi,

                       

                      The actual problem is during runtime i populate the reader.location. i.e the html component to display .html or .pdf file in air apllication

                       

                      reader.location="Url"; i.e accessing html component

                       

                      This Url is coming from server upon an http request.

                       

                      The Url may contain .html file or .pdf file

                       

                      i.e reader.location = " Url .html";   When the file is html i.e with .html extension no problem occurs there is no problem in overlapping

                       

                      But the problem occurs when the Url has .pdf extension

                       

                      i.e reader.location = " Url.pdf"; when the file is with .pdf extension i.e overlapping occurs here

                       

                      Is there a problem in displaying pdf file in within  html component, should i have to use any other approch to display pdf file from server within air application

                      am i using a wrong approach to do so...

                       

                      pls let me know, by giving me an hint

                       

                      <mx:Canvas

                       

                      id="rTE" width="100%" height="100%" borderStyle="solid" borderVisible="true" borderColor="#000000">

                       

                       

                      <mx:HTML id="reader" width="100%" height="200" y="0" locationChange="reader_locationChangeHandler(event)"

                      htmlRender="reader_htmlRenderHandler(event)" verticalScrollBarStyleName="

                      customScroll">

                       

                       

                      </mx:HTML>

                       

                       

                      </mx:Canvas>

                       

                      Thanks & Regards

                      • 8. Re: Accessing containers within viewstack
                        bspShankar Level 1

                        Hi,

                         

                        Actual problem is within my air application i am requesting for .html or .pdf file from server.

                         

                        reader.location = "Url .html"; //i.e rendering file within html component,here there is no problem

                         

                        There is no problem when file is with extension .html there is no problem with overlapping of drop down menu

                         

                        But when

                         

                        reader.location = "Url.pdf";//Problem occurs here, drop down comes behind the pdf

                         

                        is there a problem in displaying the .pdf file within html component, should i have  to use any other approach to display .pdf file during runtime within air application

                         

                        Pls let me know if the approach i used is wrong....

                        Give me an hint what should i do..........ASAP

                         

                        <mx:Canvas id="rTE" width="100%" height="100%" borderStyle="solid" borderVisible="true" borderColor="#000000">
                          <mx:HTML id="reader" width="100%" height="200" y="0" locationChange="reader_locationChangeHandler(event)"
                               htmlRender="reader_htmlRenderHandler(event)" verticalScrollBarStyleName="customScroll">
                            </mx:HTML>
                           </mx:Canvas>

                         

                        Thanks & Regards