My rss circle feed code

January 14, 2009 at 6:35 pm Leave a comment

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
//the loop at the bottom then searches the text for occurances of the words
//then counts them
var thecounter:int = 0;
var andcounter:int = 0;
var acounter:int = 0;
//standard xml loading
var entries:Array = new Array();
var xml:XML;
var newMovie:MovieClip = new MovieClip()
this.addChild(newMovie);
function onLoaded(e:Event):void
{
//trace (e.target.data);
//load the xml
xml = new XML(e.target.data);
//pull the items from the xml
var il:XMLList = xml.channel.item;
//convert first item text into a string
var str:String = il.description.text()[0];
trace(str)
//split the sting into words b looking for the gaps
var toast:Array = str.split(” “);
//loop through the first 20 words
for(var i:uint=0; i< 30; i++)
{
//trace (toast[i]);
//check for word gad and count it repeat for other words
if(toast[i] == ‘the’) {
thecounter++
//make it create some graphics
graphics.beginFill(0xff0000);
graphics.drawCircle(Math.random()*stage.stageWidth, Math.random()*stage.stageHeight, 20 * thecounter);
}
if(toast[i] == ‘and’) {
andcounter++
graphics.beginFill(0x00ff00);
graphics.drawCircle(Math.random()*stage.stageWidth, Math.random()*stage.stageHeight, 20 * andcounter);
}
if(toast[i] == ‘a’) {
acounter++
graphics.beginFill(0x0000ff);
graphics.drawCircle(Math.random()*stage.stageWidth, Math.random()*stage.stageHeight, 20 * acounter);
}
}
trace (thecounter);
trace (andcounter);
trace (acounter);
}
loader.load(new URLRequest(“http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml&#8221;));

Advertisements

Entry filed under: Advanced Web Design, FDA interactive Media Yr2.

My random image as3 code Advanced web revisited – in depth research

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


January 2009
M T W T F S S
« Dec   Feb »
 1234
567891011
12131415161718
19202122232425
262728293031  

Categories

Recent Posts


%d bloggers like this: