Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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/0/docker/10.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
我的XML在Flash中停止加载_Xml_Flash_Actionscript - Fatal编程技术网

我的XML在Flash中停止加载

我的XML在Flash中停止加载,xml,flash,actionscript,Xml,Flash,Actionscript,我有一个项目,它成功地从一个XML文件加载图像,以制作一个Flash图库。然而,它似乎突然停止了工作。我进行了故障排除,发现这是因为SWF不再加载XML文件。然而,我没有搞乱SWF。我进入FLA文件,代码是一样的。给你,作为参考 var strTitle = "THIS IS TITLE TEXT"; var strDescription = "This is descriptive"; var intCurrent = 0; var arrDescription = new Array();/

我有一个项目,它成功地从一个XML文件加载图像,以制作一个Flash图库。然而,它似乎突然停止了工作。我进行了故障排除,发现这是因为SWF不再加载XML文件。然而,我没有搞乱SWF。我进入FLA文件,代码是一样的。给你,作为参考

var strTitle = "THIS IS TITLE TEXT";
var strDescription = "This is descriptive";
var intCurrent = 0;
var arrDescription = new Array();//Stores descriptions
var arrTitle = new Array();//Stores titles
var arrMainLoc = new Array();//Stores image locations
var arrThumbLoc = new Array();//Stores thumb locations

var intCurrent:Number = 0;//Used to store the number passed from the button press

stop();
System.security.allowDomain("http:/gretchencomlydesign.com");

myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.load("imgDATA.xml");
myPhoto.onLoad = function(success)
{
trace("loaded");
var intImageCount = myPhoto.firstChild.childNodes.length;
for (i = 0; i < intImageCount; i++)
{
    arrDescription[i] = myPhoto.firstChild.childNodes[i].attributes.desc;
    arrTitle[i] = myPhoto.firstChild.childNodes[i].attributes.titl;
    arrMainLoc[i] = myPhoto.firstChild.childNodes[i].attributes.main;
    arrThumbLoc[i] = myPhoto.firstChild.childNodes[i].attributes.thumbs;
    //trace(arrTitle[i]);   //Tests Loaded titles
    //trace(arrDescription[i]);    //Tests Loaded descriptions
}
play();
//trace(myPhoto.firstChild.childNodes[0].attributes.desc);
  };
  myPhoto.onLoad = function(false)
  {
    trace("XML failed to load");
  };
var strTitle=“这是标题文本”;
var strDescription=“这是描述性的”;
var intCurrent=0;
var arrDescription=新数组()//存储描述
var arrtTitle=新数组()//商店名称
var arrMainLoc=新数组()//存储图像位置
var arrhumbloc=新数组()//存储拇指位置
var intCurrent:Number=0//用于存储按键传递的数字
停止();
System.security.allowDomain(“http://gretchencomlydesign.com”);
myPhoto=newxml();
myPhoto.ignoreWhite=true;
load(“imgDATA.xml”);
myPhoto.onLoad=函数(成功)
{
跟踪(“加载”);
var-intImageCount=myPhoto.firstChild.childNodes.length;
对于(i=0;i
它确实加载了,但现在将不再工作。我检查了,服务器是Apache,我的案例匹配。我的文件名为“imgDATA.xml”。有人经历过这样的事情吗

编辑:值得一提的是,我试图更改目标XML文件和要加载的XML文件的名称,但仍然无法加载

编辑2:在调整SWF代码之后,我得到了这个输出

loaded
onData:<pop>



<img titl="0" desc="" main="pics/pop/main/0.jpg" thumbs="pics/pop/thumbs/0.jpg"/>

<img titl="1" desc="" main="pics/pop/main/1.jpg" thumbs="pics/pop/thumbs/1.jpg"/>

<img titl="2" desc="" main="pics/pop/main/2.jpg" thumbs="pics/pop/thumbs/2.jpg"/>

<img titl="3" desc="" main="pics/pop/main/3.jpg" thumbs="pics/pop/thumbs/3.jpg"/>





</pop>
已加载
翁达塔:
这是我的XML文件:

<pop>

<img titl="0" desc="" main="pics/pop/main/0.jpg" thumbs="pics/pop/thumbs/0.jpg"/>
<img titl="1" desc="" main="pics/pop/main/1.jpg" thumbs="pics/pop/thumbs/1.jpg"/>
<img titl="2" desc="" main="pics/pop/main/2.jpg" thumbs="pics/pop/thumbs/2.jpg"/>
<img titl="3" desc="" main="pics/pop/main/3.jpg" thumbs="pics/pop/thumbs/3.jpg"/>


</pop>

在服务器的根目录下(承载xml文件的根目录下)是否有
crossdomain.xml
文件?如果没有,则需要添加它并将其内容设置为:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
   <allow-access-from domain="*" secure="false" />
</cross-domain-policy>
编辑:

尝试向XML文件添加头,否则Flash可能不知道它的XML数据:

<?xml version="1.0"?>
<pop>
<img titl="0" desc="" main="pics/pop/main/0.jpg" thumbs="pics/pop/thumbs/0.jpg"/>
<img titl="1" desc="" main="pics/pop/main/1.jpg" thumbs="pics/pop/thumbs/1.jpg"/>
<img titl="2" desc="" main="pics/pop/main/2.jpg" thumbs="pics/pop/thumbs/2.jpg"/>
<img titl="3" desc="" main="pics/pop/main/3.jpg" thumbs="pics/pop/thumbs/3.jpg"/>
</pop>

我最终解决了这个问题。我只需要调整代码,使其生成一个函数,然后调用该函数。明白了。这是工作代码

var strTitle = "THIS IS TITLE TEXT";
var strDescription = "This is descriptive";
var intCurrent = 0;
var arrDescription = new Array();//Stores descriptions
var arrTitle = new Array();//Stores titles
var arrMainLoc = new Array();//Stores image locations
var arrThumbLoc = new Array();//Stores thumb locations

var intCurrent:Number = 0;//Used to store the number passed from the button press

stop();




function processXMLData(success)
{
  if (success)
  {trace("loaded");
    var intImageCount = myPhoto.firstChild.childNodes.length;

    for (i = 0; i < intImageCount; i++)
    {
        arrDescription[i] = myPhoto.firstChild.childNodes[i].attributes.desc;
        arrTitle[i] = myPhoto.firstChild.childNodes[i].attributes.titl;
        arrMainLoc[i] = myPhoto.firstChild.childNodes[i].attributes.main;
        arrThumbLoc[i] = myPhoto.firstChild.childNodes[i].attributes.thumbs;
        trace(arrTitle[i]);//Tests Loaded titles
        trace(arrDescription[i]);//Tests Loaded descriptions

    }
    trace(arrTitle[0]);
    play();
    //trace(myPhoto.firstChild.childNodes[0].attributes.desc);
}    else
  {
    content="Today's news is not found";
  }
  }



var myPhoto=new XML();
myPhoto.ignoreWhite=true;
myPhoto.onLoad=processXMLData;
myPhoto.load("imgDATA.xml");
stop();
var strTitle=“这是标题文本”;
var strDescription=“这是描述性的”;
var intCurrent=0;
var arrDescription=新数组()//存储描述
var arrtTitle=新数组()//商店名称
var arrMainLoc=新数组()//存储图像位置
var arrhumbloc=新数组()//存储拇指位置
var intCurrent:Number=0//用于存储按键传递的数字
停止();
函数processXMLData(成功)
{
如果(成功)
{跟踪(“加载”);
var-intImageCount=myPhoto.firstChild.childNodes.length;
对于(i=0;i
从allowDomain中删除“http:/”。不知道这是否是问题所在,但这是错误的。并尝试在文件名中只使用小写字母thanks@Nick你也应该考虑使用AS3而不是AS2。你的SWF在服务器上驻留在哪里?xml在哪里?它们在同一个文件夹中吗?XML和SWF应该在同一个文件夹中,而且它们是。我想他是从同一个域加载的,所以不需要跨域文件。我只是把它放在那里看它是否有用,但忘了删除它。它没有提到SWF和XML在哪里,所以我只是猜测一下。如果有人删除或更改了跨域文件,这可以解释为什么他的SWF停止工作,即使他没有更改它。我弄乱了XML文件,但我认为除了更改一些目的地之外,我什么也没做。我想,没有什么东西会使它不可加载,或者会破坏Flash的加载功能。下面是文本,我不知道这是否是确切的XML提要,但我看到了许多错误
titl=0“
有一个结束引号,但没有开始引号,所有的
desc=“
没有值,只有一个引号而不是两个引号,等等。您可以在那里检查XML的有效性:
var strTitle = "THIS IS TITLE TEXT";
var strDescription = "This is descriptive";
var intCurrent = 0;
var arrDescription = new Array();//Stores descriptions
var arrTitle = new Array();//Stores titles
var arrMainLoc = new Array();//Stores image locations
var arrThumbLoc = new Array();//Stores thumb locations

var intCurrent:Number = 0;//Used to store the number passed from the button press

stop();




function processXMLData(success)
{
  if (success)
  {trace("loaded");
    var intImageCount = myPhoto.firstChild.childNodes.length;

    for (i = 0; i < intImageCount; i++)
    {
        arrDescription[i] = myPhoto.firstChild.childNodes[i].attributes.desc;
        arrTitle[i] = myPhoto.firstChild.childNodes[i].attributes.titl;
        arrMainLoc[i] = myPhoto.firstChild.childNodes[i].attributes.main;
        arrThumbLoc[i] = myPhoto.firstChild.childNodes[i].attributes.thumbs;
        trace(arrTitle[i]);//Tests Loaded titles
        trace(arrDescription[i]);//Tests Loaded descriptions

    }
    trace(arrTitle[0]);
    play();
    //trace(myPhoto.firstChild.childNodes[0].attributes.desc);
}    else
  {
    content="Today's news is not found";
  }
  }



var myPhoto=new XML();
myPhoto.ignoreWhite=true;
myPhoto.onLoad=processXMLData;
myPhoto.load("imgDATA.xml");
stop();