0
votes

I'm trying to load HTML/CSS from an external domain into a SWF using Actionscript 3. The data loads properly when I "test movie" out of Flash. However, when I upload the SWF to the website, it will no longer import the data. Here is an example of my code...

import flash.events.MouseEvent;
var req:URLRequest = new URLRequest("http://website.com/feeds/feed-upcoming-events.php?limit=12&format=html");
var loader:URLLoader = new URLLoader();
var cssReq:URLRequest = new URLRequest("http://website.com/feeds/feed-upcoming-events.css");
var cssLoader:URLLoader = new URLLoader();

function fileLoaded(event:Event):void
{
    this.feed_ani_mc.feed_mc.feed_txt.htmlText = loader.data;
}

function cssLoaded(event:Event):void
{
    var sheet:StyleSheet = new StyleSheet();
    sheet.parseCSS(cssLoader.data);
    this.feed_ani_mc.feed_mc.feed_txt.styleSheet = sheet;
}

loader.addEventListener(Event.COMPLETE, fileLoaded);
loader.load(req);
cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
cssLoader.load(cssReq);
3

3 Answers

0
votes

Are you sure the URL you are loading are correct? I tried http://website.com/feeds/feed-upcoming-events.php?limit=12&format=html but it returns a 404 error.

I would install Tamper Data on Firefox to see what is happening when your site is loading. Maybe you're missing a crossdomain.xml file on your server to allow you flash making external calls.

alt text

0
votes

You could listen to the following events in order to assess the reason for your data not loading.

flash.events.SecurityErrorEvent
flash.events.IOErrorEvent

A Security error sounds likely though, in which case a crossdomain policy file should solve your problem

0
votes

try this crossdomain.xml, for development servers:

<?xml version="1.0"?>
<cross-domain-policy> 
<allow-http-request-headers-from domain="*" headers="*" secure="false" /> 
<allow-access-from domain="*" secure="false" to-ports="*"/> 
</cross-domain-policy>