This is the relatively simple ActionScript used for the RSS reader on the front page.
import fl.controls.Button;
import fl.controls.TextArea;
import fl.events.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.*;
import flash.text.*;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.events.Event;
import flash.events.ProgressEvent;
var timerTrans:Boolean = false;
var timerInt = 5000;
var playTimer:Timer = new Timer(0,0);
var xml:XML = new XML();
var loader:URLLoader = new URLLoader();
var count:int = 0;
var current:int = 0;
//HEADER_text.visible = false;
loader.load(new URLRequest("http://feeds.feedburner.com/WritingSelf-publishingBookMarketing?format=xml"));
loader.addEventListener(
Event.COMPLETE,
function(evt:Event):void {
xml = XML(evt.target.data);
//trace();
count = xml.channel.item.length();
//trace(count);
printEntry(current);
RSS_btn.addEventListener(MouseEvent.CLICK, RSS_link);
}
);
function printEntry(i:int):void{
if(i==count){
current = 0;
i = 0;
}
TITLE.text = xml.channel.title;
HEADER_text.titles_mc.HEADER.text = "" + xml.channel.item[i].title;
HEADER_text.titles_mc.DATE.text = xml.channel.item[i].pubDate;
//titles_mc.alpha = 0;
HEADER_text.feed_link.addEventListener(MouseEvent.CLICK, clickHandler);
current++;
textIn();
startTimer();
}
function startTimer():void{
playTimer = new Timer(timerInt, 1);
playTimer.addEventListener("timerComplete", textOut);
//timerInt = (timerInt*2);
playTimer.start();
//trace("timer playing");
}
function clickHandler(e:Event):void{
var detailURL = new URLRequest("" + xml.channel.item[current-1].link);
navigateToURL(detailURL, "_blank");
}
function RSS_link(e:Event):void{
var detailURL = new URLRequest("http://feeds.feedburner.com/WritingSelf-publishingBookMarketing");
navigateToURL(detailURL, "_blank");
}
function textIn():void{
var yInTween:Tween = new Tween(HEADER_text, "y", Regular.easeInOut, 120, 31, 14, false);
//yInTween.addEventListener(TweenEvent.MOTION_FINISH, detailsIn);
}
function textOut(e:Event):void{
var yInTween:Tween = new Tween(HEADER_text, "y", Regular.easeInOut, 31, 120, 14, false);
yInTween.addEventListener(TweenEvent.MOTION_FINISH, function detailsIn(et:Event):void{printEntry(current)});
} |