A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: rss info to dynamic text field

  1. #1
    Member
    Join Date
    Oct 2009
    Location
    New England
    Posts
    79

    rss info to dynamic text field

    i have an rss feed loaded into flash via this code:

    var xml:XML = new XML();
    var loader:URLLoader = new URLLoader();
    loader.load(new URLRequest("my feeds url"));
    loader.addEventListener(
    Event.COMPLETE,
    function(evt:Event):void {
    xml = XML(evt.target.data);
    trace(xml.channel.item[0].description);
    }
    }
    );

    and now i want to display the contents of the feed in a dynamic text field which is placed inside a mc on the stage. any ideas??

  2. #2
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    You can access the dynamic text field's text attribute via its instance name by using the instance name of the Movie Clip that it's sitting in.

    Code:
    this.myMovieClip.myDynamicText.text = xml.channel.item[0].description;
    You can set the instance name for a Symbol in the Properties window, after copying an instance of that Symbol to your main Stage from the Library. Just click on it once, pull up the Properties window, and fill in an instance name. =)

  3. #3
    Member
    Join Date
    Oct 2009
    Location
    New England
    Posts
    79
    thats great worked out well thanks.
    i am also looking to add a timer that will have the text field display the next item in the feed. any suggestions?

  4. #4
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    Try out the Timer class:

    Code:
    var myTimer:Timer = new Timer(500);
    myTimer.addEventListener(TimerEvent.TIMER, timedFunction);
    
    myTimer.start();
    
    function timedFunction(event:TimerEvent):void {
        trace(xml.channel.item[myTimer.currentCount - 1].description;
    }
    You should be able to loop through the RSS feed data using the counter on the Timer object.

  5. #5
    Member
    Join Date
    Oct 2009
    Location
    New England
    Posts
    79
    that worked perfectly! you are a bigamist husband to all things that were and all that will be

  6. #6
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    Well, it's good to know I'm so closely connected to those things... I wouldn't say I'm married to them all, though.

    Do me a favour and resolve this thread, if you please. You can find that in the Thread Tools menu above and to the right of your first post. =)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center