开发者

Getting error to access webservice

开发者 https://www.devze.com 2022-12-26 17:14 出处:网络
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.

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();


       f开发者_开发技巧or( 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>


your initApp() doesnt seem to be called from anywhere, (unless its listed outside of the script youve pasted) so your user might be null when you are trying to add the EventListener

0

精彩评论

暂无评论...
验证码 换一张
取 消