【flash player】flash 加载 xml的导航菜单实例代码

时间:2016-06-23  来源:导航菜单  阅读:

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.111cn.net.xml");

//www.111cn.net.xml文档代码



 
 
  
  
  
  
  
  
  
 

 
  
  
  
  
  
  
  
  
 

 
  
  
  
  
  
  
 

 
  
  
  
 

 
  
  
  
  
 

 
  
  
  
  
 

 
  
  
  
  
  
 

 
  
  
 

 
  
  
  常见问题" href="1.1" />
  
  
 

【flash player】flash 加载 xml的导航菜单实例代码

http://m.bbyears.com/wangyetexiao/24833.html

推荐访问:flash插件 flashfxp flash控件 flash动画制作 flashftp flashget flash动画
相关阅读 猜你喜欢
本类排行 本类最新