外部接口不返回变量,该变量是从XML数据生成的url

时间:2010-08-17 10:19:56

标签: flash actionscript-3

这是问题所在: 基本上我有一些XML生成的数据,我正在进入闪存。我正在使用ExternalInterface.call将一些数据导出到Array中的JavaScript。出于某种原因除了url之外的一切都被返回 - 我试图追踪网址 - 工作正常。我在同一个地方设置了一个带有标准网址的变量 - 工作正常。

总而言之,它非常令人困惑!

以下是一段代码,看看是否有人可以提供任何建议!

    shedProductName = productName;
  shedColourName = new String(xmlData.data.item[clickedItem-1].product[name1].colours.colour.(@colour==colourCode2));  
  //shedColourImgLoc = new String(xmlData.data.item[clickedItem-1].product[name1].colours.colour.(@location));
  shedProdImgLoc = new String(xmlData.data.item[clickedItem-1].product[name1].@webimage); // this fails!
  trace(shedProdImgLoc); // this returns the correct result! :-S
  var testVar:String = new String("http://www.google.com"); // this works!!
  if (ExternalInterface.available) {
  flash.external.ExternalInterface.call("sendToJavaScript", [shedProductName, shedColourName, testVar, shedProdImgLoc]);

1 个答案:

答案 0 :(得分:0)

尝试在发送之前转义URL字符串。

...
var testVar:String = new String("http://www.google.com");
testVar = escape(testVar); 
...

这导致一个字符串,其中所有不常见的字符转换为URL友好的等价物,在这种情况下它变为:

  

的http%3A // www.google.com

我希望这有帮助!