主题:  求助[急]

Bain

职务:普通成员
等级:1
金币:1.0
发贴:78
注册:2001/11/29 11:53:50
#12003/12/6 0:03:46

var drag = 0.4;
var flex = 0.6;
var menuEN = new Array("News", "Clud", "Gymnasium", "KTV", "Frenid", "Marry", "Find");
var menuZH = new Array("Ê×Ò³", "ԭ֭ԭζ", "½¡Éí³¡Ëù", "¾Æ°ÉKTV", "½»ÓÑÖÐÐÄ", "Õ÷»éÆôʾ", "ѰÈËÆôʾ");
var menuURL = new Array("index.asp", "#", "index_jianshen.asp", "index_ktv.asp", "index_center.asp", "index_zhenghuen.asp", "#");
var menuColor = new Array(0xFF6699, 0x00A2FF, 0x96D302, 0xFFC600, 0xFF5400, 0xCD7DE1, 0x02D396);
var mBlock = this.attachMovie("mblock", "mb", 6);
mBlock._y = 5;
mBlock.goalX = -100;
mBlock.onEnterFrame = function() {
	this.Step = this.Step*flex+(this.goalX-this.px)*drag;
	this.px += this.Step;
	this._x = this.px;
	if (this.sOut && this._xscale<99.5) {
		this._xscale += (100-this._xscale)/8;
	}
	if (this.sIn && this._xscale>0.1) {
		this._xscale += -this._xscale/8;
	}
};
var MBColor = new Color(mBlock);
for (var i = 0; i<menuZH.length; i++) {
	pipi.start([1, 1]);
	var theItem = this.attachMovie("MenuItem", "Item"+i, i+10);
	theItem._x = i*84;
	theItem.mColor = menuColor[i];
	theItem.URL = menuURL[i];
	theItem.mc_ZH.itext.text = menuZH[i];
	theItem.mc_EN.itext.text = menuEN[i];
	theItem.onEnterFrame = function() {
		if (this.fadeOut) {
			if (this.topLine._alpha<99.5) {
				this.topLine._alpha += (100-this.topLine._alpha)/8;
			}
			if (this.mc_EN._alpha>0.5) {
				this.mc_EN._alpha += -this.mc_EN._alpha/0;
			}
			if (this.mc_ZH._xscale<00) {
				this.mc_ZH._xscale += 2;
				this.mc_ZH._yscale += 2;
			}
		}
		if (this.fadeIn) {
			if (this.mc_EN._alpha<99.5) {
				this.mc_EN._alpha += (100-this.mc_EN._alpha)/8;
			}
			if (this.topLine._alpha>0.5) {
				this.topLine._alpha += -this.topLine._alpha/8;
			}
			if (this.mc_ZH._xscale>100) {
				this.mc_ZH._xscale -= 2;
				this.mc_ZH._yscale -= 2;
			}
		}
	};
	theItem.onRollOver = function() {
		mBlock.goalX = this._x+42;
		mBlock.sOut = true;
		mBlock.sIn = false;
		MBColor.setRGB(this.mColor);
		new Color(this.topLine).setRGB(this.mColor);
		this.fadeOut = true;
		this.fadeIn = false;
	};
	theItem.onRollOut = function() {
		mBlock.sOut = false;
		mBlock.sIn = true;
		this.fadeIn = true;
		this.fadeOut = false;
	};
	theItem.onRelease = function() {
		getURL(this.URL);
	};
}
stop();


以上代码可以正常运行.但是因为如果要更改数据,需要打开FLASH修改.很麻烦.后来加上了预读XML来实现数据外读.但是一直无法时间,请高手们指教.
以下是我更改后的代码:

var drag = 0.4;
var flex = 0.6;
[color=Red]
var total;
xmlobj = new XML();
xmlobj.ignoreWhite = true;
xmlobj.load("system_config.xml");
xmlobj.onload = function(success) {
	if (success) {
		var menuEN = new Array(parseXML("menu_name_en"));
		var menuZH = new Array(parseXML("menu_name_cn"));
		var menuURL = new Array(parseXML("menu_web_url"));
		var menuColor = new Array(parseXML("menu_style_color"));
	} else {
		trace("error");
	}
};
[/color]

var mBlock = this.attachMovie("mblock", "mb", 6);
mBlock._y = 5;
mBlock.goalX = -100;
mBlock.onEnterFrame = function() {
	this.Step = this.Step*flex+(this.goalX-this.px)*drag;
	this.px += this.Step;
	this._x = this.px;
	if (this.sOut && this._xscale<99.5) {
		this._xscale += (100-this._xscale)/8;
	}
	if (this.sIn && this._xscale>0.1) {
		this._xscale += -this._xscale/8;
	}
};
var MBColor = new Color(mBlock);
for (var i = 0; i<menuZH.length; i++) {
	pipi.start([1, 1]);
	var theItem = this.attachMovie("MenuItem", "Item"+i, i+10);
	theItem._x = i*84;
	theItem.mColor = menuColor[i];
	theItem.URL = menuURL[i];
	theItem.mc_ZH.itext.text = menuZH[i];
	theItem.mc_EN.itext.text = menuEN[i];
	theItem.onEnterFrame = function() {
		if (this.fadeOut) {
			if (this.topLine._alpha<99.5) {
				this.topLine._alpha += (100-this.topLine._alpha)/8;
			}
			if (this.mc_EN._alpha>0.5) {
				this.mc_EN._alpha += -this.mc_EN._alpha/0;
			}
			if (this.mc_ZH._xscale<00) {
				this.mc_ZH._xscale += 2;
				this.mc_ZH._yscale += 2;
			}
		}
		if (this.fadeIn) {
			if (this.mc_EN._alpha<99.5) {
				this.mc_EN._alpha += (100-this.mc_EN._alpha)/8;
			}
			if (this.topLine._alpha>0.5) {
				this.topLine._alpha += -this.topLine._alpha/8;
			}
			if (this.mc_ZH._xscale>100) {
				this.mc_ZH._xscale -= 2;
				this.mc_ZH._yscale -= 2;
			}
		}
	};
	theItem.onRollOver = function() {
		mBlock.goalX = this._x+42;
		mBlock.sOut = true;
		mBlock.sIn = false;
		MBColor.setRGB(this.mColor);
		new Color(this.topLine).setRGB(this.mColor);
		this.fadeOut = true;
		this.fadeIn = false;
	};
	theItem.onRollOut = function() {
		mBlock.sOut = false;
		mBlock.sIn = true;
		this.fadeIn = true;
		this.fadeOut = false;
	};
	theItem.onRelease = function() {
		getURL(this.URL);
	};
}

[color=Red]
function parseXML(stype) {
	returnValue = "";
	var e = xmlobj.firstChild.childNodes;
	total = e.length;
	for (i=0; i<total; i++) {
		switch (sType) {
		case "menu_name_en" :
			returnValue += "'"+e[i].attributes["menu_name_en"]+"',";
			break;
		case "menu_name_cn" :
			returnValue += "'"+e[i].attributes["menu_name_cn"]+"',";
			break;
		case "menu_web_url" :
			returnValue += "'"+e[i].attributes["menu_web_url"]+"',";
			break;
		default :
			returnValue += e[i].attributes["menu_style_color"]+",";
			break;
		}
		if (i == 6) {
			trace (returnValue.substr(0, eval(returnValue.length)-1).toString());	
			return (returnValue.substr(0, eval(returnValue.length)-1).toString());
		}
	}
}[/color]
stop();



UndeadCraft

职务:版主
等级:4
金币:10.0
发贴:1993
注册:2001/5/28 17:37:43
#22003/12/6 9:00:14
你要等XML load成功后才能attachMovie



Bain

职务:普通成员
等级:1
金币:1.0
发贴:78
注册:2001/11/29 11:53:50
#32003/12/6 10:17:31
已经成功了,如果用trace读parseXML("menu_name_en").是可以正常取值的.但是就无法付到arrary中.

后来我在trace(menuEN),数据为空.我不知道为什么?
高手.可以帮忙修改一下么?



UndeadCraft

职务:版主
等级:4
金币:10.0
发贴:1993
注册:2001/5/28 17:37:43
#42003/12/6 10:34:39
把fla和xml打个包发上来吧



Bain

职务:普通成员
等级:1
金币:1.0
发贴:78
注册:2001/11/29 11:53:50
#52003/12/6 14:12:42

相关文件:点这儿打开

谢谢了.

如果好了.请发到我的MAIL中.nj_ppg@163.com.

谢谢!



UndeadCraft

职务:版主
等级:4
金币:10.0
发贴:1993
注册:2001/5/28 17:37:43
#62003/12/8 10:06:39
刚看了一下,发现是你返回的值,是一个,而不是分开的原因。所以会这样。
本来你想返回"a","b","c"的形式,结果返回的却是""a","b","c""
你可以trace一下menuEN[0]就知道了。我暂是还没想到办法来解决。你自己想想吧



Bain

职务:普通成员
等级:1
金币:1.0
发贴:78
注册:2001/11/29 11:53:50
#72003/12/8 13:51:27
好的.谢谢!