Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将数据(HTML)从外部域加载到Flash Actionscript 3中_Flash_Actionscript 3 - Fatal编程技术网

将数据(HTML)从外部域加载到Flash Actionscript 3中

将数据(HTML)从外部域加载到Flash Actionscript 3中,flash,actionscript-3,Flash,Actionscript 3,我正在尝试使用ActionScript3将HTML/CSS从外部域加载到SWF中。当我从Flash中“测试电影”时,数据正确加载。但是,当我将SWF上传到网站时,它将不再导入数据。下面是我的代码示例 import flash.events.MouseEvent; var req:URLRequest = new URLRequest("http://website.com/feeds/feed-upcoming-events.php?limit=12&format=html"); var

我正在尝试使用ActionScript3将HTML/CSS从外部域加载到SWF中。当我从Flash中“测试电影”时,数据正确加载。但是,当我将SWF上传到网站时,它将不再导入数据。下面是我的代码示例

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

您确定正在加载的URL是正确的吗?我试过了,但它返回了404错误

我会安装,看看发生了什么,当你的网站加载。可能您的服务器上缺少一个crossdomain.xml文件,该文件允许您进行外部呼叫


您可以收听以下事件,以评估数据未加载的原因

flash.events.SecurityErrorEvent flash.events.IOErrorEvent flash.events.SecurityErrorEvent flash.events.IOErrorEvent
不过,听起来很可能出现安全错误,在这种情况下,跨域策略文件应该可以解决您的问题

请尝试此crossdomain.xml,用于开发服务器:

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


在代码示例中,我用“website.com”替换了实际域。我将检查篡改数据,并对crossdomain.xml进行一些研究。周一回到办公室后,我会告诉你我发现了什么。我丢失了crossdomain.xml文件,我也在想同样的事情。周一回到办公室后,我会对整个“跨域”的东西做一些研究,并让你知道进展如何。关键是你的SWF和HTML是否在同一个域上(意味着整个域,包括端口#相同)。如果是,这肯定不是一个跨域问题,但在其他方面可能是。