flash 加载 xml的导航菜单实例代码
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.zzzyk.com.xml");
//www.zzzyk.com.xml文档代码
<?xml version="1.0" encoding="utf8"?>
<foot>
<items name="首 页" href="1"></items>
<items name="关于三校" href="2">
<item name="校长寄语" href="1.1" />
<item name="本校文化" href="1.1" />
<item name="组织机构" href="1.1" />
<item name="发展历史" href="1.1" />
<item name="三校新闻" href="1.1" />
<item name="员工风采" href="1.1" />
<item name="联系我们" href="1.1" />
</items>
<items name="三校名师" href="3">
<item name="民法" href="1.1" />
<item name="刑法" href="1.1" />
<item name="民诉法" href="1.1" />
<item name="刑诉法" href="1.1" />
<item name="行政法" href="1.1" />
<item name="三国" href="1.1" />
<item name="商经" href="1.1" />
<item name="理论法学" href="1.1" />
</items>
<items name="班次设置" href="4">
<item name="公告栏" href="1.1" />
<item name="报名流程" href="1.1" />
<item name="三校班次" href="1.1" />
<item name="教学环境" href="1.1" />
<item name="考生感言" href="1.1" />
<item name="光荣榜" href="1.1" />
</items>
<items name="司考图书" href="5">
<item name="最新书讯" href="1.1" />
<item name="学员推荐" href="1.1" />
<item name="销售排行" href="1.1" />
</items>
<items name="重点法条" href="6">
<item name="全国人民代表大会" href="1.1" />
<item name="最高人民易做图" href="1.1" />
<item name="最高人民检查院" href="1.1" />
<item name="国务院" href="1.1" />
</items>
<items name="免费下载" href="7">
<item name="内部资料" href="1.1" />
<item name="音频下载" href="1.1" />
<item name="司考真题集" href="1.1" />
<item name="司考笔记" href="1.1" />
</items>
<items name="司考茶座" href="8">
<item name="司考动态" href="1.1" />
<item name="热身篇" href="1.1" />
<item name="起跑篇" href="1.1" />
<item name="跨越篇" href="1.1" />
<item name="冲刺篇" href="1.1" />
</items>
<items name="加入我们" href="9">
<item name="招商政策" href="1.1" />
<item name="申请加盟" href="1.1" />
</items>
<items name="服务中心" href="10">
<item name="报名须知" href="1.1" />
<item name="付款方式" href="1.1" />
<item name="常见问题" href="1.1" />
<item name="意见反馈" href="1.1" />
<item name="书店代理点" href="1.1" />
</items>
</foot>
补充:flash教程,动画技术