8 Replies Latest reply on Jul 4, 2009 12:30 PM by rbz.

    Flex 3 - HTTPService problem (ithink?)

    rbz.

      Hey!

       

      firstly; i'm usualy a forum ninja and never need to post, but im really struggling with this bit of code i wonder if anyone could help?.

       

      Basically, when it loads it gets the data from an XML file and loads it into a list, (it doesn't use XMLCollections or Arrays or anything).

       

      That works fine,

       

      When i delete the selected item it removes it from the XML fine (does this by sending a POST request to a PHP file),

       

      The problem is that when i send a reqeuest to refresh the XML, (call the init() ) method again, it doesnt update. At all. unless i press it a few times.

       

      (im guessing its the Cache of the HTTPService, i've tried almost everything to disable, once i close the browser and reload it the correct items are shown)

       

      i've attacthed the entire file below. please take a look and if you could help, it would be much appriciated - ive been stuck with this for hours.

       

      also; Rename MySnorklets.txt to MySnorklets.mxml, the file is added through a parent using popupwindow.

       

      Thanks, Rob.

        • 1. Re: Flex 3 - HTTPService problem (ithink?)
          leybniz Level 4

          your post lacks most valuable info, which browser are you using?

          • 2. Re: Flex 3 - HTTPService problem (ithink?)
            rbz. Level 1

            Sorry!

             

            Internet explorer 7.

            Vista Ultimate

             

            is there anything else?

            • 3. Re: Flex 3 - HTTPService problem (ithink?)
              leybniz Level 4

              since your attachment still in queue.. I can only guess, but I think it's a browser/or whatever problem,

              as far as I know HTTPService doesn't have any cache at all, when Flash Player runs inside IE 7 as ActiveX it utilizes IE methods for URL retrieving directly, so the only problem I see is IE Cache, randomize your URL requests to avoid such effects further.

               

              If you feel this message answers your question or helps, please mark it respectively

              • 4. Re: Flex 3 - HTTPService problem (ithink?)
                rbz. Level 1

                yeah, i've been sniffing around, but how about converting it to an XMLCollection so i could remove it easily like that?

                 

                this is the contents of the file.

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute" width="636" height="446" title="Snork" showCloseButton="true" hideEffect="hEffect" showEffect="sEffect" color="#FFFFFF" status="My Snorklets" visible="true">
                       
                        <mx:Script>
                        <![CDATA[
                        
                         import mx.rpc.events.ResultEvent;
                         import mx.controls.Alert;
                       
                            [Bindable]
                            private var xData:XML;
                            [Bindable]
                            private var username:String;
                       
                                   
                        public function init():void
                            {
                                username = "rob";
                                xmlService.send();
                            }
                   
                            public function resultHandler(event:ResultEvent):void
                            {
                               
                                xData = event.result as XML;
                            }
                           
                                public function wat(event:ResultEvent):void
                            {
                                init();
                                               
                            }
                                   
                        public function DeleteSnorklet():void
                               {
                                   var UsernameSD:String = username;
                                var IDSD:String = idSnorklet.text;
                                this.Delete.send({username: UsernameSD, id: IDSD});                
                              }   
                           
                               
                        ]]>
                    </mx:Script>
                   
                   
                    <mx:HTTPService id="xmlService"
                        url="http://www.example.com/users/{username}/itemlist.xml"
                        result="resultHandler(event)"
                        resultFormat="e4x"
                        showBusyCursor="true"/>
                <mx:HTTPService id="Delete" url="http://www.example.com/RemoveFromXML.php" showBusyCursor="true" method="POST" result="wat(event)" resultFormat="text"  useProxy="false"/>
                           
                    <mx:List id="out" width="185" height="340" color="#000000" dataProvider="{xData.snork.snorklet.@name}"  selectedIndex="0" y="26" x="10"/>
                    <mx:Label x="10" y="6" text="Snorklets" color="#000000"/>
                    <mx:Label x="203" y="6" text="Description" color="#000000"/>
                   
                    <mx:Text x="203" y="29" width="403" height="119" color="#000000" alpha="1.0" text="{xData.snork[out.selectedIndex].snorklet.@description}"/>
                    <mx:Image x="203" y="173" width="403" height="193"  source="{xData.snork[out.selectedIndex].snorklet.@screenshot}"/>
                    <mx:Label x="203" y="154" text="Screenshot" color="#000000"/>
                    <mx:Label id="idSnorklet" x="81" y="6" color="#000000" text="{xData.snork[out.selectedIndex].snorklet.@id}"/>
                    <mx:Button  id="Deletebtn" x="542" y="374" label="Delete" click="DeleteSnorklet()" color="#000000"/>
                              
                               
                                           
                       
                   
                </mx:TitleWindow>  

                • 5. Re: Flex 3 - HTTPService problem (ithink?)
                  leybniz Level 4

                  public function init():void  {

                     username = "rob";

                     // randomize url to avoid caching

                     xmlService.url = 'http://www.example.com/users/{username}/itemlist.xml?rnd=' + new Date().getMilliseconds().toString();
                     xmlService.send();

                  }

                   

                  Easily and XMLCollection are not synonyms

                   

                  If you feel this message answers your question or helps, please mark it respectively

                  1 person found this helpful
                  • 6. Re: Flex 3 - HTTPService problem (ithink?)
                    rbz. Level 1

                    Ah i see!

                     

                    yeah this is getting somewhere that was helpfull.

                     

                    However its still not removing the item from the list :\?

                    • 7. Re: Flex 3 - HTTPService problem (ithink?)
                      rbz. Level 1

                      bump o-o

                      • 8. Re: Flex 3 - HTTPService problem (ithink?)
                        rbz. Level 1

                        Alright, i managed to fix it myself.

                         

                        i put it in an ArrayCollection and did it that way, then i removed it from the ArrayCollection whilst sending the post.

                         

                        But many thanks Alexander Mazuruk anyway!

                         

                        (this helped alot: http://forums.adobe.com/message/2082932#2082932)

                         

                        Message was edited by: rbz.