多图片轮换,
图片来源于SWF外部文件夹,
图片路径数据用XML方式保存在SWF外,
第一 FLASH读取XML数据
//定义数组用来保存将来会从XML中得到的数据。
bannerImage = new Array();
bannerUrl = new Array();
//加载XML load the XML
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success) {
family = this.firstChild;
images = family.childNodes;
totalBanners = images.length;
for (var i = 0; i
_root.bannerImage[i] = images[i].attributes.image;
_root.bannerUrl[i] = images[i].attributes.url;
};
my_xml.load("ad.xml");//加载动作。
这样,XML中的数据就存到了两个数组中了,
以后用到时,直接从数据变量中读取就可以了
如,点中后,连到目标URL上,这个URL每个广告图对应的都不同,就是从XML中得到的,现在存在数组
getURL(bannerUrl[2]);
用上面这样的方式 就可以了。
No comments:
Post a Comment