帮忙看下这个flash导航源码哪里出了错

2025-12-14 21:58:20
推荐回答(1个)
回答1:

他自己没写点之后的效果

// XML Menu Demo
// Coded by Darkvn 2003-0-03
// Mail: Darkvn@blueidea.com
// CopyRight(C) Blueidea.com

System.useCodePage=true; // Unicode Surpport

var ItemCurOpen=null;
var MainItemBGColor=0xe0e0e0;
var MainItemWidth=200;
var MainItemHeight=20;
var MainItemSpace=2;
var MainItemTextColor=0x333333;
var SubItemIndent=20;
var SubItemWidth=180;
var SubItemHeight=18;
var SubItemSpace=1;
var SubItemBGColor=0xf0f0f0;
var SubItemTextColor=0x333333;
var HintWidth=250;
var HintHeight=20;
var HintTextColor=0x666666;

var XMLData=new XML();
XMLData.ignoreWhite=true;
XMLData.onLoad=XMLLoad;
XMLData.load("menu.xml");

function XMLLoad(success){
if(success){
menuNode=this.firstChild;
createEmptyMovieClip("menu",10);
menu._x=20;
menu._y=30;
showMenuNode(menu,menuNode);
}
}

function showMenuNode(mc,node){
for(var i=0;i mc.createEmptyMovieClip("item"+i,i);
var theItem=mc["item"+i];
theItem.index=i;
theItem.node=node.childNodes[i];
theItem.createEmptyMovieClip("citem",1);
DrawItem(theItem.citem,node.childNodes[i].attributes.label);
theItem.citem.onRollOver=function(){
this.bg.over=true;
this.bg.out=false;
if(!this.open && this._parent.node.attributes.hint!=null){
this._parent.createEmptyMovieClip("hint",2);
var theHint=this._parent.hint;
theHint._y=this._parent._height;
DrawHint(theHint,this._parent.node.attributes.hint);
}
}
theItem.citem.onRollOut=function(){
this.bg.over=false;
this.bg.out=true;
if(!this.open){
this._parent.hint.removeMovieClip();
}
}
theItem.citem.onReleaseOutSide=function(){
this.bg.over=false;
this.bg.out=true;
if(!this.open){
this._parent.hint.removeMovieClip();
}
}
theItem.citem.onRelease=function(){
if(!this.open && this._parent.node.hasChildNodes){
this._parent.createEmptyMovieClip("subItem",3);
this._parent.subItem._y=this._parent._height;
this._parent.subItem._x=SubItemIndent;
showSubMenu(this._parent.subItem,this._parent.Node);
this.open=true;
doClose(ItemCurOpen);
ItemCurOpen=this._parent;
}else{
if(this.open){
this._parent.subItem.removeMovieClip();
this.open=false;
ItemCurOpen=null;
}
}
}

if(i>0){
theItem.onEnterFrame=function(){
var theUpper=this._parent["item"+(this.index-1)];
var dx=theUpper._y+theUpper._height+MainItemSpace-this._y;
if(Math.abs(dx)>1) this._y+=dx/3;
}
}
}
}

function doClose(theItem){
theItem.subItem.removeMovieClip();
theItem.hint.removeMovieClip();
theItem.citem.open=false;
}

function showSubMenu(mc,node){
for(var i=0;i mc.createEmptyMovieClip("subitem"+i,i);
var theSub=mc["subitem"+i];
DrawSubItem(theSub,node.childNodes[i].attributes.label);
theSub._y=i*(SubItemHeight+SubItemSpace);
theSub.onRollOver=function(){
this.bg._alpha=50;
}
theSub.onRollOut=function(){
this.bg._alpha=100;
}
theSub.onReleaseOutSide=function(){
this.bg._alpha=100;
}
}
}

function DrawHint(mc,text){
mc.createTextField("hint",1,0,0,HintWidth,HintHeight);
mc.hint.textColor=HintTextColor;
mc.hint.text=text;
mc.hint.selectable=false;
}
function DrawItem(mc,text){
mc.createEmptyMovieClip("bg",1);
with(mc.bg){
beginFill(MainItemBGColor,100);
moveTo(0,0);
lineTo(MainItemWidth,0);
lineTo(MainItemWidth,MainItemHeight);
lineTo(0,MainItemHeight);
lineTo(0,0);
}
mc.bg.onEnterFrame=function(){
if(this.over){
if(this._alpha<99.5) this._alpha+=100-(this._alpha)/4;
}
if(this.out){
if(this._alpha>30.5) this._alpha+=(30-this._alpha)/4;
}
}
mc.bg._alpha=30;
mc.createTextField("label",2,0,0,MainItemWidth,MainItemHeight);
mc.label.textColor=MainItemTextColor;
mc.label.text=text;
mc.label.selectable=false;
}

function DrawSubItem(mc,text){
mc.createEmptyMovieClip("bg",1);
with(mc.bg){
beginFill(SubItemBGColor,100);
moveTo(0,0);
lineTo(SubItemWidth,0);
lineTo(SubItemWidth,SubItemHeight);
lineTo(0,SubItemHeight);
lineTo(0,0);
}
mc.createTextField("label",2,0,0,SubItemWidth,SubItemHeight);
mc.label.textColor=SubItemTextColor;
mc.label.text=text;
mc.label.selectable=false;
}

stop();

XML文件