5 Replies Latest reply on Jul 10, 2009 6:19 AM by kglad

    Open Links

    tpatterson2007

      I'm building an rss reader in flash. I have the rss displaying with no problem, the problem is, I need each title to open the web page to a particular site.
      The link is the same for every header, so I assumed it wouldn't be that hard, but since I'm very new Flash and followed a tutorial to get this working, I have no idea how to do this

       

      Can somebody look at my Action Script and help me out?

       

      import fl.managers.StyleManager;

       

      var logFormat:TextFormat = new TextFormat();
      logFormat.font = "Verdana";
      logFormat.size = 10;
      logFormat.bold = true;

       

      StyleManager.setStyle("textFormat", logFormat);

       

      var rssLoader:URLLoader = new URLLoader ();
      var rssURL:URLRequest = new URLRequest("http://www.vegasdsports.com/feeds/nba.php");
      rssLoader.addEventListener(Event.COMPLETE, rssLoaded);
      rssLoader.load(rssURL);

       

      var rssXML:XML = new XML();
      rssXML.ignoreWhitespace = true;

       

      function rssLoaded(evt:Event):void {
          rssXML = XML(rssLoader.data);
          //trace(rssXML);
         
          for(var item:String in rssXML.channel.item) {
              liLog.addItem( {label:rssXML.channel.item[item].title} );
          }
      }
      for(var item:String in rssXML.channel.item) {
      liLog.onRelease = function:void() {
      getURL("http://www.vegasdsports.com/feeds/nfl.php");
      }
      };

       

       

       

      Thanks in advance

        • 1. Re: Open Links
          kglad Adobe Community Professional & MVP

          that's a mixture of as2 and as3 code.  are you claiming that with that code, you have an rss feed displaying?

          • 2. Re: Open Links
            tpatterson2007 Level 1

            Yes I do have an RSS Feed showing

             

            I followed a couple of tutorials on how to do it, but they didn't discuss anything about linking the titles

            You can see for yourself here, http://www.vegasdsports.com/feeds/widgets.php

             

            Is there an easier way to do this?

            • 3. Re: Open Links
              kglad Adobe Community Professional & MVP

              that can't be published for as2 and it can't be published for as3.  are you sure all that code is in your fla?

               

              if so, zip your fla, upload it to a server and post a link.

              • 4. Re: Open Links
                tpatterson2007 Level 1

                Yes. I'm sure that is the code.

                Here is the .fla file

                • 5. Re: Open Links
                  kglad Adobe Community Professional & MVP

                  1.  you're publishing for as3, not as2.

                   

                  2.  the code you posted in this forum is NOT the same as the code in your fla.  specifically, the as2 code you posted is not in the fla and, if it were, you could not publish a swf.  the code in red is as2 code.

                   

                   


                   

                  import fl.managers.StyleManager;

                   

                  var logFormat:TextFormat = new TextFormat();
                  logFormat.font = "Verdana";
                  logFormat.size = 10;
                  logFormat.bold = true;

                   

                  StyleManager.setStyle("textFormat", logFormat);

                   

                  var rssLoader:URLLoader = new URLLoader ();
                  var rssURL:URLRequest = new URLRequest("http://www.vegasdsports.com/feeds/nba.php");
                  rssLoader.addEventListener(Event.COMPLETE, rssLoaded);
                  rssLoader.load(rssURL);

                   

                  var rssXML:XML = new XML();
                  rssXML.ignoreWhitespace = true;

                   

                  function rssLoaded(evt:Event):void {
                      rssXML = XML(rssLoader.data);
                      //trace(rssXML);
                     
                      for(var item:String in rssXML.channel.item) {
                          liLog.addItem( {label:rssXML.channel.item[item].title} );
                      }
                  }
                  for(var item:String in rssXML.channel.item) {
                  liLog.onRelease = function:void() {
                  getURL("http://www.vegasdsports.com/feeds/nfl.php");
                  }

                  };

                   

                   

                   

                   

                   

                  3.  here's your corrected code with links to clicked items:

                   

                  import fl.managers.StyleManager;
                  import fl.events.ListEvent;

                   

                  var logFormat:TextFormat = new TextFormat();
                  logFormat.font = "Verdana";
                  logFormat.size = 10;
                  logFormat.bold = true;

                   

                  StyleManager.setStyle("textFormat", logFormat);

                   

                  var rssLoader:URLLoader = new URLLoader ();
                  var rssURL:URLRequest = new URLRequest("http://www.vegasdsports.com/feeds/nba.php");
                  rssLoader.addEventListener(Event.COMPLETE, rssLoaded);
                  rssLoader.load(rssURL);

                   

                  var rssXML:XML = new XML();
                  rssXML.ignoreWhitespace = true;

                   

                  function rssLoaded(evt:Event):void {
                      rssXML = XML(rssLoader.data);
                     
                     
                      for(var item:String in rssXML.channel.item) {
                          liLog.addItem( {label:rssXML.channel.item[item].title,link:rssXML.channel.item[item].link} );
                      }
                  }

                   

                  liLog.addEventListener(ListEvent.ITEM_CLICK,clickedLogF);

                   

                  function clickedLogF(e:ListEvent){
                      navigateToURL(new URLRequest((liLog.getItemAt(e.index).link)));
                  }