views:

25

answers:

3

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);
A: 

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

jdecuyper
I substituted "website.com" for the actual domain in my code example. I'll check out Tamper Data, and do some research on crossdomain.xml. I'll let you know what I find when back in the office on Monday.
mikemick
I was missing the crossdomain.xml file
mikemick
A: 

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

PatrickS
I'm thinking the same thing. I'll do some research on the whole "crossdomain" stuff, and let you know how it went, when I get back into the office on Monday.
mikemick
The key is whether your SWF and the HTML are on the same domain (meaning the entire domain, including port # are identical) or not. If they are, it's definitely not a crossdomain issue, but otherwise it probably is.
fenomas
A: 

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>
Eugene