4 Replies Latest reply: May 24, 2010 7:20 AM by Ned Murphy RSS

    Dynamic data Integration trouble

    Kristtee Community Member

      Hi There

      I am trying to load, read, and get data from xml into a listbox, textarea, and a dynamic textField. I was able to get it all right but the dynamic textField data does not update as i select item in the listbox. Another thing is thing is when I click on dynamic textfield it should open page in browser - how can i do that?
      Please help
      Appreciate your time.
      Thanks
      Krish
      --------------------
      var xmlLoader:URLLoader = new URLLoader();
      var xmlData:XML = new XML();

      xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
      xmlLoader.load(new URLRequest("http://rssfeeds.tv.adobe.com/learn-flash-professional-cs4.xml"));
      //lb is ListBox component in stage
      lb.addEventListener(Event.CHANGE, itemChange);

      function itemChange(e:Event):void
      {
      ta.text = lb.selectedItem.data;//ta is TextArea in stage
      }

      function LoadXML(e:Event):void {
      xmlData=new XML(e.target.data);
      parseData(xmlData);
      }
      function parseData(loadedData:XML):void {
      //trace(loadedData.channel.item);
      //trace(loadedData.channel.item.length());
      var titleList:XMLList=loadedData.channel.item;
      for (var i:uint = 0; i<titleList.length(); i++) {
      lb.addItem({label:titleList.title.text()[i], data:titleList.description.text()[i]});
      uri.text = titleList.link.text()[i];
      //uri is dynamic TextField on stage
      }
      }
      --------------------------------
      Fla file is http://www.naturecareasia.com/test/learnCS4.flv.fla
      -----------------------------

        • 1. Re: Dynamic data Integration trouble
          dmeN Community Member

          Hmm, are you sure your text field is dynamic, font is embedded, and you have given it an instance name of ta? I copy pasted your code directly, put a list box and a text field on stage with instance names of lb and ta and it worked just fine. Put a trace in your change handler to help debug... but I think it's got to be something with your field as the code does work.

          As for opening in a browser... just use a navigateToURL in your change handler.

          • 2. Re: Dynamic data Integration trouble
            Ned Murphy CommunityMVP

            You don't do anything to store the data for the link, nor to update the textfield with it when a selection is made, nor do you add a hyperlink for it to the textfield.

             

            var xmlLoader:URLLoader = new URLLoader();
            var xmlData:XML = new XML();
            var uriLinks:Array = new Array();

            xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
            xmlLoader.load(new URLRequest("http://rssfeeds.tv.adobe.com/learn-flash-professional-cs4.xml"));
            //lb is ListBox component in stage
            lb.addEventListener(Event.CHANGE, itemChange);

            function itemChange(e:Event):void
            {
            ta.text = lb.selectedItem.data;//ta is TextArea in stage
            uri.htmlText = "<a href='"+uriLinks[lb.selectedIndex]+"' target='_blank'>"+uriLinks[lb.selectedIndex]+"</a>";
            }

            function LoadXML(e:Event):void {
            xmlData=new XML(e.target.data);
            parseData(xmlData);
            }
            function parseData(loadedData:XML):void {
            //trace(loadedData.channel.item);
            //trace(loadedData.channel.item.length());
            var titleList:XMLList=loadedData.channel.item;
            for (var i:uint = 0; i<titleList.length(); i++) {
            lb.addItem({label:titleList.title.text()[i], data:titleList.description.text()[i]});
            uriLinks.push(titleList.link.text()[i]);

            //uri.text = titleList.link.text()[i];
            //uri is dynamic TextField on stage
            }
            }

            • 3. Re: Dynamic data Integration trouble
              Kristtee Community Member

              Hello NedMurphy

              Many many  thanks. You rock. Appreciate your time and help.

              Krish

              • 4. Re: Dynamic data Integration trouble
                Ned Murphy CommunityMVP

                You're welcome Krish