#include "XMLSA.as"
// Setup text fields
temp_txt.text = "Loading";
temp_txt.TextFormat.align = "center"
// Load the XML/RSS
weather = new XMLSA();
// Load the RSS file
weather.load("http://news.gc.ca/cfmx/ccnews/xml/rss/Regional_en.xml");
weather.onLoad = function(success){
if (success) {
// Check RSS version and make shorthand
if(weather.channel[0].item){
// Where to find data items for RSS 0.91
newsNode = weather.channel[0];
} else {
// Where to find data items for RSS 1.0 and 2.0
newsNode = weather;
}
// Store the number of news items
rssCount = newsNode.item.length;
// Call the showNext function every 5 seconds
setInterval(showNext,1000);
} else {
// Show error message
temp_txt.text = "Error loading XML";
}
}
// Function for getting next entry
showNext = function(){
// Zero the counter if the last article has been shown
if(rssCounter == rssCount || rssCounter == undefined){ rssCounter = 0; }
// Get values from XMLSA array
temp_txt.text = newsNode.item[rssCounter].description.getValue();
var str0 = temp_txt.text;
var str1 = temp_txt.text;
var str2 = str1.indexOf("|");
var str3 = str1.substr(0, str2);
temp_txt.text = str3
str1 = temp_txt.text;
str2 = str1.indexOf("/");
str3 = str1.substr(str2 + 1, 15);
temp_txt.text = str3;
var str01 = str0.indexOf("Conditions",0);
var str02 = str0.substr(str01 + 11, str0.length);
var str03 = str02.indexOf("|",0);
var str04 = str02.substr(0,str03);
conditions_txt.text = str04;
body._y = head._y + head._height;
varStr = str04.indexOf("Overcast",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("cloudy_mc","cloudy_mc",26);
_root.weather_mc.image_mc.cloudy_mc._alpha = 75;
}
varStr = str04.indexOf("Drizzle",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("rain_mc","rain_mc",26);
_root.weather_mc.image_mc.rain_mc._alpha = 75;
}
varStr = str04.indexOf("Rain",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("rain_mc","rain_mc",26);
_root.weather_mc.image_mc.rain_mc._alpha = 75;
}
varStr = str04.indexOf("Thunder",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("thunder_mc","thunder_mc",26);
_root.weather_mc.image_mc.thunder_mc._alpha = 75;
}
varStr = str04.indexOf("Partly Cloudy",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("partly_cloudy_mc","partly_cloudy_mc",26
);
_root.weather_mc.image_mc.partly_cloudy_mc._alpha = 75;
}
varStr = str04.indexOf("Mostly Cloudy",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("mostly_cloudy_mc","mostly_cloudy_mc",26
);
_root.weather_mc.image_mc.mostly_cloudy_mc._alpha = 75;
}
varStr = str04.indexOf("Cloudy",0);
if( varStr >= 0){
if(varStr < 5) {
_root.weather_mc.image_mc.attachMovie("cloudy_mc","cloudy_mc",26);
_root.weather_mc.image_mc.cloudy_mc._alpha = 75;
}
}
varStr = str04.indexOf("Sunny",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("sunny_mc","sunny_mc",26);
_root.weather_mc.image_mc.sunny_mc._alpha = 75;
}
varStr = str04.indexOf("Snow",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("snow_mc","snow_mc",26);
_root.weather_mc.image_mc.snow_mc._alpha = 75;
}
varStr = str04.indexOf("Flurries",0);
if( varStr >= 0){
_root.weather_mc.image_mc.attachMovie("snow_mc","snow_mc",26);
_root.weather_mc.image_mc.snow_mc._alpha = 75;
}
}
timmiejon - 31 Oct 2006 19:07 GMT
Throw in any URL - it won't be formatted correctly, but IT WILL pull down the information - I've tried it with several off-domain RSS feeds and it works.
timmiejon - 31 Oct 2006 19:24 GMT
My bad - it only seems to work with this URL http://www.wunderground.com/auto/rss_full/global/stations/71623.xml any ideas why? How could flash think that this is on the local domain?
TimSymons - 02 Nov 2006 21:30 GMT
You mean that this works when you "test" your movie from within Flash? It's
supposed to. The security settings will take effect once the browser or Flash
Player loads the file.
I ran into the same issue when doing some testing on some of Yahoo! API stuff.
Thought it was working great (because I was testing in Flash) then posted to my
site and it didn't work.
Tim
javatech - 03 Nov 2006 14:55 GMT
You can access data across domains only from sites that have put a cross-domain
policy file at the root of their server, to allow Flash programs to access
cross-domain data.
See http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14213