dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Help with AS3 Scrolling News Ticker

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    102

    Help with AS3 Scrolling News Ticker

    I am trying to make a AS3 version of a scrolling news ticker although i seem to be having trouble. The code below doesn't seem to be working although its not throwing any errors. I think its not loading my xml nodes or something.

    All i am trying to do is it to eventually load an rss feed and scroll a selected set of nodes. For now i just tried to get it to display an xml formated file since rss is xml formated. Ultimately for this example i just want it to display the title attribute of every item.

    What am i doing wrong?

    Code:
    news_txt.x = 1024.0;
    var count:int;
    var textnode:String;
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.TEXT;
    loader.addEventListener(Event.COMPLETE, onComplete);
    
    loader.load(new URLRequest("http://www.xlr8mobile.com/widgetdata/beowulf/audio.xml"));
    
    
    function onComplete(event:Event):void
    {
    	try {
    		var news:XML = new XML(event.target.data);
    		news_txt.addEventListener(Event.ENTER_FRAME, onEnter);
    		for each (var ticker:XML in news.newsitem.text()) {
    			textnode += ticker + " ";
    			news_txt.width += textnode.length;
    			news_txt.text = textnode;
    		}
    	
    
    
    	} catch (e:TypeError) {
    
    		news_txt.x = 512.0;
    		news_txt.text = "Could not create valid xml instance";
    	}
    }
    
    function onEnter(event:Event):void
    {
    	//scrolls the text field
    	news_txt.x--;
    	if (news_txt.x == -1024.0) {
    		news_txt.x = 1024.0;
    	}
    }
    
    trace("text position " + news_txt.x)
    Is their a simpler way to create this in AS3 then how i am doing it? If there is i would love to see an example of how to do it.

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Have you done traces to see what is not working?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    102
    yes i have tried various simple traces to make sure functions and stuff are getting called and they seem to be. I think its an issue with my xml. The xml seems to be getting loaded though is it something with my nodes and not calling the right node maybe?

    Any help would be appreciated.

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    trace the nodes.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483

    AS3 XML News Ticker Source

    Hi ctoomey. You can download the source files for AS3 XML News Ticker v3 from my Lab. I hope it helps you.
    Last edited by garion1; 01-08-2009 at 03:31 AM.
    "A day without laughter is a day wasted." - Charlie Chaplin

  6. #6
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Hi there,

    I made a similar ticker with a different approach using TextFormat(), substring() and slice().

    Check a demo and download source files here

    Hope that helps!

    Mike

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