最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
flash 加载 xml的导航菜单实例代码
时间:2010-05-21 编辑:简简单单 来源:一聚教程网
flash 加载 xml的导航菜单实例代码
//Stage.align = "TL";
//Stage.scaleMode = "noScale";
System.useCodepage = true;
/////////////////////////
var srcFoot:Object;
var navLeng:Number;
var nav_xml:XML = new XML();
nav_xml.ignoreWhite = true;
nav_xml.onLoad = function(isSuccess)
{
if (isSuccess) {
srcFoot = nav_xml.firstChild;
navLeng = srcFoot.childNodes.length;
arrangeMenu();
} else {
//load error XML;
}
};
function arrangeMenu()
{
for (var i:Number = 0; i < navLeng; i++) {
var num:Number = 1 + 100 * (i - 1) + 100;
this.attachMovie("nav", "nav" + (i + 1), this.getNextHighestDepth());
this["nav" + (i + 1)]._x = num;
this["nav" + (i + 1)]._y = 0;
this["nav" + (i + 1)].isTxt.text = srcFoot.childNodes[i].attributes.name;
this["nav" + (i + 1)].isTxt.selectable = false;
//
if (srcFoot.childNodes[i].childNodes.length > 0) {
this.attachMovie("sub_mc", "sub" + i, this.getNextHighestDepth());
this["sub" + i]._x = num;
this["sub" + i]._y = 27;
/*问题就是在这里,为什么只有最后一个尼*/
for (var j:Number = 0; j < srcFoot.childNodes[i].childNodes.length; j++) {
var numSub:Number = 8 + 21 * (j - 1) + 21;
this["sub" + i].attachMovie("sub", "btn" + j, this.getNextHighestDepth());
//trace(srcFoot.childNodes[i].childNodes[j]);
this["sub" + i]["btn" + j]._y = numSub;
//trace(numSub)
this["sub" + i]["btn" + j].isTxt.text = srcFoot.childNodes[i].childNodes[j].attributes.name;
}
//trace(srcFoot.childNodes[i].childNodes.length);
}
}
for (var i:Number = 1; i <= navLeng; i++) {
this["nav" + i].onRollOver = function()
{
var temp:Number = parseInt(substring(this._name, 4, 2));
trace(temp);
this.gotoAndPlay(2);
this._parent["sub" + (temp - 1)].gotoAndPlay(2);
trace(this._name);
};
this["nav" + i].onRollOut = function()
{
var temp:Number = parseInt(substring(this._name, 4, 2));
this.gotoAndPlay(7);
this._parent["sub" + (temp - 1)].gotoAndPlay(7);
};
}
}
nav_xml.load("www.111com.net.xml");
//www.111com.net.xml文档代码
-
上一个: FLASH调用XML数据代码实例教程
-
下一个: flash右上角关闭效果as 代码
相关文章
- FLASH软件帧编辑功能怎么使用 06-22
- FLASH软件常用上色工具怎么使用 06-19
- flash怎么制作遮罩图片切换动画 06-19
- FLASH制作春意盎然花园效果 06-18
- 利用ae制作碎片文字动画 06-15
- flash图片怎么替换 06-14