4 Replies Latest reply on Sep 28, 2009 5:04 AM by _Natasha_

    event.result = null: but it's not null, I can see in debugger; it has a value

    enginço

      sebep.jpg

       

      Hi, I'm trying to read an xml file as shown on screenshot, and event.result has null value. But on varieables window, it has an xml value.

      What is the my fault?

       

      thanx...

        • 2. Re: event.result = null: but it's not null, I can see in debugger; it has a value
          _Natasha_ Level 4

          Hi,

           

          it's normal.

           

          tarife is a root element for XML and it's shown.

          But then you write event.result.tarife it looks up child elements of root with name tarife. And it's null.

          var result:XML = XML(event.result); // it's your result

          var innerChilds:XMLList = result.*; // it's children

          • 3. Re: event.result = null: but it's not null, I can see in debugger; it has a value
            enginço Level 1

            I found the problem, I guess it's a bug. In this case result is very big. And tooltip shows anyting. I said before, In variables window I can see the value of XML. You can try with my code. In fact code is working.

             

             

            Code:

             

            TarifeService.as

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

             

            package xmlservice
            {
                import flash.events.*;
               
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.http.HTTPService;
                import mx.utils.ArrayUtil;

             

                public class TarifeService
                {
                    private var service:HTTPService;

             

                    [Bindable]
                    public var tarifeler:ArrayCollection;

             

                    public function TarifeService(url:String)
                    {
                        service = new HTTPService();
                        service.url = url;

                        service.resultFormat = "e4x";
                        service.addEventListener(ResultEvent.RESULT, resultHandler);
                        service.send();
                    }

             

                    private function resultHandler(event:ResultEvent):void
                    {
                        var result:XML = event.result;
                    }
                }
            }

             

             

            tarife.xml

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

             

            <?xml version="1.0" encoding="UTF-8"?>
            <tarife>
              <il id="34-1">
                <ilce name="Arnavutköy"></ilce>
                <ilce name="Avcılar"></ilce>
              </il>
              <il id="34-2">
                <ilce name="Adalar"></ilce>
                <ilce name="Ataşehir"></ilce>
                <ilce name="Kadıköy">
                  <year y="2009">

                    <mx:MXML xmlns:mx="http://www.adobe.com/2006/mxml">
                    <mx:Panel id="p1" width="100%" height="230" title="Oturum Aç">
                        <mx:Form>
                            <mx:FormItem labelWidth="80" width="100%" label="Kullanıcı:" color="#ffffff">
                                <mx:TextInput id="txtUser" width="110" color="#ffffff"/>
                            </mx:FormItem>
                            <mx:FormItem labelWidth="80" width="100%" label="Şifre:" color="#ffffff">
                                <mx:TextInput id="txtPassword" displayAsPassword="true" width="110" color="#ffffff"/>
                            </mx:FormItem>
                            <mx:FormItem labelWidth="80" width="100%" label="" color="#ffffff">
                                <mx:HBox>
                                    <mx:Button id="btnLogin" label="Giriş" width="110"/>
                                </mx:HBox>
                            </mx:FormItem>
                            <mx:FormItem labelWidth="80" width="100%" label="">
                                <mx:CheckBox label="Beni Hatırla" color="#ffffff"/>
                            </mx:FormItem>
                        </mx:Form>
                    </mx:Panel>
                    </mx:MXML>
                  </year>
                </ilce>
                <ilce name="Maltepe"></ilce>
                <ilce name="Pendik"></ilce>
                <ilce name="Sancaktepe"></ilce>
              </il>
            </tarife>

            • 4. Re: event.result = null: but it's not null, I can see in debugger; it has a value
              enginço Level 1

              thanx _Natasha_, I found the problem, the code is working, only tooltip couldn't show the value of variable. Yes you are right, may be debugger can't recognize variables after dot.