Getting error to access webservice.

Posted by nemade-vipin on Stack Overflow See other posts from Stack Overflow or by nemade-vipin
Published on 2010-04-08T12:02:59Z Indexed on 2010/04/09 7:23 UTC
Read the original article Hit count: 269

Filed under:
|
|

hi friend, I have created webapplication in which I am getting the error:-

ypeError: Error #1009: Cannot access a property or method of a null object reference. at FlexSBTSApp/displayString()[E:\Users\User1\Documents\Flex Builder 3\FlexSBTSApp\src\FlexSBTSApp.mxml:38] at FlexSBTSApp/___FlexSBTSApp_Button1_click()[E:\Users\User1\Documents\Flex Builder 3\FlexSBTSApp\src\FlexSBTSApp.mxml:118]

my code is:-

   import mx.controls.*;


     [Bindable]
        private var childName:ArrayCollection;
     [Bindable]
        private var childId:ArrayCollection;  
        private var photoFeed:ArrayCollection;
        private var arrayOfchild:Array;
        [Bindable]
        private var childObj:Child; 
    public var user:SBTSWebService;

    public function initApp():void
    {
       user = new SBTSWebService();

       user.addSBTSWebServiceFaultEventListener(handleFaults);

    }

    public function displayString():void
    {
           // Instantiate a new Entry object.
           var newEntry:GetSBTSMobileAuthentication = new GetSBTSMobileAuthentication();
            newEntry.mobile=mobileno.text;
            newEntry.password=password.text;
            user.addgetSBTSMobileAuthenticationEventListener(authenticationResult);

            user.getSBTSMobileAuthentication(newEntry);

    }

    public function handleFaults(event:FaultEvent):void
    {
        Alert.show("A fault occured contacting the server. Fault message is: " + event.fault.faultString);
    }

    public function authenticationResult(event:GetSBTSMobileAuthenticationResultEvent):void
    {
        if(event.result != null && event.result._return>0) 
        {

           if(event.result._return > 0)
           {
             var UserId:int = event.result._return;
              getChildList(UserId);       
              viewstack2.selectedIndex=1;
           }
           else
           {
             Alert.show("Authentication fail");
           }


        }

    }
  public function getChildList(userId:int):void
  {
     var childEntry:GetSBTSMobileChildrenInfo = new GetSBTSMobileChildrenInfo();
     childEntry.UserId = userId;
     user.addgetSBTSMobileChildrenInfoEventListener(sbtsChildrenInfoResult);
     user.getSBTSMobileChildrenInfo(childEntry);
  }
   public function sbtsChildrenInfoResult(event:GetSBTSMobileChildrenInfoResultEvent):void
    {
        if(event.result != null && event.result._return!=null) 
        {

        arrayOfchild  = event.result._return as Array;
        photoFeed = new ArrayCollection(arrayOfchild);
        childName = new ArrayCollection();


       for( var count:int=0;count<photoFeed.length;count++)
       {
           childObj = photoFeed.getItemAt(count,0) as Child;
           childName.addItem(childObj.strName); 

       }

    }
    }

]]>

<mx:Panel width="500" height="300"
    headerColors="[#000000,#FFFFFF]">

    <mx:TabNavigator id="viewstack2" selectedIndex="0" creationPolicy="all" 
    width="100%" height="100%"> 
        <mx:Form label="Login Form">
         <mx:FormItem label="Mobile NO:">
            <mx:TextInput id="mobileno" />
         </mx:FormItem>
        <mx:FormItem label="Password:">
            <mx:TextInput displayAsPassword="true" id="password" />
       </mx:FormItem>
        <mx:FormItem>
            <mx:Button label="Login" click="displayString()"/>
       </mx:FormItem>
        </mx:Form>


           <mx:Form label="Child List">
              <mx:Label width="100%" color="blue" 
                   text="Select Child."/>


              <mx:RadioButtonGroup id="radioGroup"/>
                 <mx:Repeater id="fieldRepeater" 
                                dataProvider="{childName}">
                                <mx:RadioButton groupName="radioGroup" 
                                            label="{fieldRepeater.currentItem}" value="{fieldRepeater.currentItem}"/>
                 </mx:Repeater>


          </mx:Form>

          <mx:Form label="Child Information">



          </mx:Form>
          <mx:Form label="Trace Path">

          </mx:Form>
    </mx:TabNavigator>

</mx:Panel>

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about mxml