主题:  音乐按钮?

iyou_5d

职务:普通成员
等级:1
金币:0.0
发贴:125
#12003/7/21 13:18:37
谁能教我做音乐的按钮啊,我找了许多圆文件,都是很生硬的,在暂停和开始时不能淡入淡入,这怎么做啊?


╰☆流郎

iyou_5d

职务:普通成员
等级:1
金币:0.0
发贴:125
#22003/7/21 15:16:49
flowingice,你这个没有淡入淡出啊?


╰☆流郎

Mozier

职务:管理员
等级:5
金币:11.0
发贴:2994
#32003/7/21 16:54:42
//扩展Sound对象的方法
Sound.prototype.fade = function (fadeType, fadeDuration) {
	this.fadeDuration = (fadeDuration * 1000) / 100;
	this.fadeType = fadeType;
	this.currentVolume = this.getVolume ();
	this.intID = setInterval (function (thisObj) {
		thisObj.doFade (thisObj.fadeType);
	}, this.fadeDuration, this);
	this.doFade = function (fadeType) {
		if (fadeType == "out") { //Sound 淡出
			this.setVolume (this.currentVolume--);
			if (this.getVolume () <= 0) {
				this.onFadeComplete ();
				clearInterval (this.intID);
			}
		}
		else if (fadetype == "in") { //Sound 淡入
			this.setVolume (this.currentVolume++);
			if (this.getVolume () >= 100) {
				this.onFadeComplete ();
				clearInterval (this.intID);
			}
		}
	};
};
okApp = function () {
	trace ("oh yes!");
};
controlBtn.labels.text = "play";
//新建Sound对象并邦定库里的声音文件
mySound = new Sound ();
mySound.attachSound ("soundLoop");
mySound.onFadeComplete = okApp;
//按钮控制
controlBtn.onRelease = function () {
	if (click == null) {
		mysound.start ();
		mySound.fade ("in", 2);
		click = "";
		controlBtn.labels.text = "stop";
	}
	else {
		mySound.fade ("out", 2);
		click = null;
		controlBtn.labels.text = "play";
	}
};

编辑历史:[这消息被麽子编辑过(编辑时间2003-07-21 16:56:19)]