This is a script that pulls data from a text feed and displays the Stock value from within that feed. It works just fine when I test the movie but when I try to publish it in a web page it does not display the live data in IE or Chrome. I’m just using the default publish options and I’m also trying to use it on a Digital Signage player that is essentially rendering a web page in IE.
import flash.net.URLLoader;
import flash.net.URLRequest;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void{
var rawRSS:String = e.target.data;
var pattern:RegExp = /<TD.*?TD>/sg;
var pieces:Array = rawRSS.match(pattern);
var CH = pieces[2].split(">");
var CHR = CH[1].split("<");
var CHRW:String = String(CHR[0]);
var CHRWT:String = CHRW.substr(0,5);
stock_price.text = CHRWT;
var loc:int = pieces[4].indexOf("+",0);
var gain:String = String(pieces[4].charAt(loc));
//trace(gain);
if (gain == "+"){
stock_price.textColor = 0x00CC33;
}
else {
stock_price.textColor = 0xFF0000;
}
}
loader.load(new URLRequest("http://www.nasdaq.com/aspxcontent/NasdaqRSS.aspx?data=quotes&symbol=CHRW"));
If you run your swf from a web server, it is not allowed to fetch data from another domain, unless that domain allows it in a crossdomain.xml file, and Nasdaq’s doesn’t.