我正在创建一个Flash网站,它通过我们的讲师给我们使用的xml文件加载外部信息。在flash示例中,我们获得了xml导入正常,将xml文件中的图像和文本加载到页面上,但是当我复制确切的图层并将它们粘贴到我的站点的场景中时,只加载图像。我已将我的Flash站点保存在与示例站点完全相同的位置,并将xml文件保存在同一目录中。这是flash中的actionscript代码:
mediaFolder = "book/";
//
xmlObject = new XML();
xmlObject.onLoad = readMedia;
xmlObject.ignoreWhite = true;
xmlObject.load("book.xml");
//
stop();
//
function readMedia(success) {
if (success == true) {
// Root node
rootNode = xmlObject.firstChild;
// Size of book/CD collection = number of child nodes
sizeOfCollection = rootNode.childNodes.length;
// Current node = first child node
currentNode = rootNode.firstChild;
// Display next book/CD.
drawItem();
}
}
function drawItem() {
// Title
title.text = currentNode.childNodes[0].firstChild;
// Author
authorName.text = currentNode.childNodes[1].firstChild;
// Load in external JPEG of book/CD cover
coverImage.loadMovie(mediaFolder + currentNode.childNodes[2].firstChild);
// Book price and currency symbol
bookPrice.text = currentNode.childNodes[4].attributes.currency + " " + currentNode.childNodes[4].firstChild;
//
debug();
}
//
nextBook.onRelease = function() {
nextNode = currentNode.nextSibling;
if (nextNode == null) {
break;
} else {
currentNode = nextNode;
drawItem();
}
};
//
previousBook.onRelease = function() {
nextNode = currentNode.previousSibling;
if (nextNode == null) {
break;
} else {
currentNode = nextNode;
drawItem();
}
};
// Read books XML file.
books.onRelease = function() {
xmlFile = "book.xml";
mediaFolder = "book/";
xmlObject.load(xmlFile);
};
// Read music XML file.
music.onRelease = function() {
xmlFile = "music.xml";
mediaFolder = "music/";
xmlObject.load(xmlFile);
};
/*
Display debugging information about each XML node,
into fields on the right side of the screen.
*/
function debug() {
debugCurrentNode = currentNode;
debugCurrentNodeChildNodes = currentNode.childNodes;
debugCurrentNodeChildNodes0 = currentNode.childNodes[0];
debugCurrentNodeChildNodes0child = currentNode.childNodes[0].firstChild;
debugCurrentNodeChildNodes1 = currentNode.childNodes[1];
debugCurrentNodeChildNodes1child = currentNode.childNodes[1].firstChild;
}
代码是正确的,因为它加载到示例Flash站点中。这是它加载的xml文件之一:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<BOOK_COLLECTION>
<BOOK>
<TITLE>Hi</TITLE>
<AUTHOR>Jon Wozencroft</AUTHOR>
<BOOKCOVER>brody.jpg</BOOKCOVER>
<ISBN>00-456754674-11</ISBN>
<PRICE Currency="$">44.25</PRICE>
</BOOK>
<BOOK>
<TITLE>Actionscript using Flash MX</TITLE>
<AUTHOR>Colin Moock</AUTHOR>
<BOOKCOVER>asdg.jpg</BOOKCOVER>
<ISBN>00-4567-65785-11</ISBN>
<PRICE Currency="$">24.50</PRICE>
</BOOK>
<BOOK>
<TITLE>The Design Of Everyday Things</TITLE>
<AUTHOR>Donald Norman</AUTHOR>
<BOOKCOVER>norman.jpg</BOOKCOVER>
<ISBN>00-477754674-11</ISBN>
<PRICE Currency="$">16.50</PRICE>
</BOOK>
<BOOK>
<TITLE>Maeda@Media</TITLE>
<AUTHOR>John Maeda</AUTHOR>
<BOOKCOVER>media.jpg</BOOKCOVER>
<ISBN>00-422567-65785-11</ISBN>
<PRICE Currency="$">17.00</PRICE>
</BOOK>
</BOOK_COLLECTION>
答案 0 :(得分:0)
好吧,首先,我会问你的讲师,因为不了解你的环境很难猜出是怎么回事
但由于正在加载图像而文本没有加载,我的第一个猜测是你根本没有嵌入你从xml分配动态文本的文本字段使用的字体。
你正在使用adobe flash ide吗?如果你这样做,只需单击文本字段然后点击“嵌入”按钮即可嵌入字体。当然,嵌入将由文本字段使用的字体......