The scenario:
I have a flash website (here) that imports some of its content from a wordpress site (here) via the Wordpress's RSS (I added a plugin to include pages in the RSS). This isn't a brilliant idea I know, but for a long list of reasons that I won't go into it's the setup I'm stuck with :/
The Problem:
When importing the RSS feed (it's downloaded into the SWF at runtime and read like an XML), I can't get the filesize. This means the preloader isn't accurate (I just manually guessed a number for it to work with for now, which obviously will grow over time). How do I get this file size?
I know there may be certain settings on the server that compresses the feed/files (GZip or such), but I'm very unfamiliar with wordpress architecture and despite my best efforts I couldn't find where this setting would be applied.
This is the preloader update code. The 113*1024 is where I want to put rss_loader.bytesTotal (the loader of the WordPress content), but when I do rss_loader.bytesTotal returns as 0:
function update_loading(e:Event):void{ var total:Number = stage.loaderInfo.bytesTotal + (113 * 1024) + css_loader.bytesTotal; var loaded:Number = stage.loaderInfo.bytesLoaded + rss_loader.bytesLoaded + css_loader.bytesLoaded; if (total == loaded) { updatePicture(360); loading_mc.perc.text = "100%"; removeEventListener(Event.ENTER_FRAME,update_loading); nextFrame(); } else { var deg:Number = (loaded / total) * 360; updatePicture(deg); loading_mc.perc.text = String(int((loaded / total) * 100))+"%"; }}
Here's the RSS import code, though I don't believe it's very relevant:
var rss_xml:XML = new XML();var post_xml:XML = new XML();var page_xml:XML = new XML();var rss_loader:URLLoader;rss_loader = new URLLoader(new URLRequest("http://news.sulsc.org/feed"));function rss_loaded(e:Event):void{ rss_xml = XML(e.target.data); var rss_raw:String = String(rss_xml); rss_raw = rss_raw.split(":encoded").join(""); rss_raw = rss_raw.split("\n").join(""); rss_raw = rss_raw.split('<p style="text-align: right;">').join('<p class="right">'); rss_raw = rss_raw.split('<p style="text-align: center;">').join('<p class="centre">'); rss_raw = rss_raw.split('<p style="text-align: left;">').join('<p class="left">'); rss_raw = rss_raw.split('<p style="text-align: justify;">').join('<p class="just">'); var heading_replace:RegExp = new RegExp("(</h[0-9]>)(<h[0-9]>)","g9"); var underline_replace:RegExp = new RegExp('<span style="text-decoration: underline;">(.*?)</span>',"gi"); var bold_replace:RegExp = new RegExp('<strong>(.*?)</strong>',"gi"); var italic_replace:RegExp = new RegExp('<em>(.*?)</em>',"gi"); rss_raw = rss_raw.replace(heading_replace,'$1<p class="space"></p>$2'); rss_raw = rss_raw.replace(underline_replace,'<u>$1</u>'); rss_raw = rss_raw.replace(bold_replace,'<b>$1</b>'); rss_raw = rss_raw.replace(italic_replace,'<i>$1</i>'); var page_test:RegExp = new RegExp("http://(news.|www.|)sulsc\\.org/(|wordpress/)\\?page_id=[0-9]+","gi"); page_xml = XML(rss_raw); post_xml = XML(rss_raw); rss_xml = null; for (var i:uint; i<post_xml.channel.item.length(); i++) { if (page_test.test(post_xml.channel.item[i]) == true) { post_xml.channel.item[i] = ""; i--; } if (i == post_xml.channel.item.length()-1) { rss_loader.bytesLoaded = 113 * 1024; } }}