5 Replies Latest reply on Mar 5, 2010 7:08 PM by flash search

    problem in timer

    flash search

      Hi all I am having a problem in timer function i have an application which will fatch xml data which is image and video and show all the data one by one after a time period.I am using HTTPservice to retrive the data  from xml.Please help me.Is it possible?please reply attaching the xml file with this.

       

      <?xml version="1.0" encoding="utf-8"?>
      <catalogue> 
            <item>
             <type>image</type>
             <source>1.jpg</source>
             <id>asd</id>
             <duration>7</duration>
          </item> 
            <item>
             <type>video</type>
             <source>sheep.flv</source>
             <id>asd</id>
             <duration>7</duration>
          </item>
          <item>
             <type>image</type>
             <source>1.jpg</source>
             <id>asd</id>
             <duration>7</duration>
          </item>   
      </catalogue>

        • 2. Re: problem in timer
          Sam Souhrada Level 1

          I would use the HTTPService class to get the XML... You can then listen for various events (like the end of the video, etc)

           

          http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html

           

           

          Video Player:

           

          http://blog.flexexamples.com/2007/08/05/building-a-basic-controller-for-the-videodisplay-c ontrol/

          • 3. Re: problem in timer
            flash search Level 1

            Hi all thanks for ur reply

                 i am attaching the detail program i used in this appllication it,s an air application.the code is:

            <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"

             

                initialize="listviewer.send()"

             

                applicationComplete="fullscreenmode()"

             

                >

             

                <mx:Script>

             

                    <![CDATA[

             

                        import mx.controls.Alert;

             

                        import mx.rpc.events.FaultEvent;

             

                        import mx.collections.ArrayCollection;

             

                        import mx.rpc.events.ResultEvent;

             

                        [Bindable]

             

                        private var mainArray:ArrayCollection;

             

                        private function resultEvent(event:ResultEvent):void{

             

                                mainArray=event.result.catalogue.item   

             

                                var imageArray:Array = new Array();

             

                                 for (var i:uint=0; i < mainArray.length; i++) {

             

                                      if(mainArray[i]["type"] == "image"){                             

             

                                      abc.source=(mainArray[i]["source"]);

             

                                      }

             

                                      else{

             

                                      dfg.source=(mainArray[i]["source"]);

             

                                      }

             

                                    }

             

                               

             

                        }

             

                        private function fullscreenmode():void{

             

                        stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

             

                       

             

                        }

             

                       

             

                    ]]>

             

                </mx:Script>

             

               

             

                <mx:Label  id="asd"/>

             

                <mx:Image id="abc"/>

             

                <mx:VideoDisplay id="dfg"/>

             

                <mx:HTTPService id="listviewer" result="resultEvent(event)"       

             

                    url="data/list.xml"

             

                    />

             

            </mx:WindowedApplication>

             

            but i want to view the data one by one for a time being what type it is. and also check for updation of data after a full circle completion.

            • 4. Re: problem in timer
              Gregory Lafrance Level 6

              Just to confirm, you want to get all the data at once using HTTPService, but you want the data to be used to add controls to the UI one by one using a timer?

               

              In that case just process the data in the result handler, and after the data has been processed, create a Timer object with whatever repeat delay you wish, 100ms, 1 sec, etc. and in the TimerEvent create and add the component.

               

              If this post answers your question or helps, please mark it as such.


              Greg Lafrance - Flex 2 and 3 ACE certified

              www.ChikaraDev.com

              Flex / AIR Development, Training, and Support Services

              1 person found this helpful
              • 5. Re: problem in timer
                flash search Level 1

                Hi Greg

                   Thanks for your reply. it will help me out I am sure. I am new in action script and trying to implement this. But not yet solved. Sir can you please give some example or tutorial link. So that I can get an idea in brie.

                 

                Thanks and regards