我仿韩国菜单,由于其源代码是FlashMx as 1.0编写的,而我采用的是FlashMx2004 as 2.0制作的,故要有点改进。
第一个菜单的源代码
放在main scene frame上
var drag = 0.1; //震动参数
var flex = 0.7; //震动参数
var wordCHArray = new Array("课堂首页","课程介绍","精彩课堂","视频欣赏","电子文档","疑难问答","影视社区");
var wordENArray = new Array("Index","Intro","Course","Video","Document","FAQ","Forum");
var menuColor = new Array(0xFFCC00,0x3399CC,0x96D302,0xFFC600,0xFF5400,0x6699CC,0x02D396); //设置各颜色
var url = new Array("index.htm","#","course/course.htm","#","other/e-learning.htm","#","#");
var block = this.attachMovie("diamond_mc","mb",0); //链接diamond_mc影片
block._x = -1000;
block.Step = 0;
block.px = 0;
block.goalX = -100;
block.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/4;
}
var MBColor=new Color(block);
for (var i:Number = 0; i <= wordCHArray.length-1; i++){
var theItem = this.attachMovie("word_mc","word"+i,i+10); //i+10为深度,必须
theItem._x = i*100;
theItem.wordCH.chn.text = wordCHArray[i];
theItem.wordEN.eng.text = wordENArray[i];
theItem.URL = url[i];
theItem.mColor = menuColor[i];
theItem.onRollOver = function() {
block.goalX = this._x+50;
block.sOut = true;
block.sIn = false;
MBColor.setRGB(this.mColor);
new Color(this.wordCH).setRGB(0xFF9933);
new Color(this.wordEN).setRGB(0xFF9933);
this.wordCH._x -= 5;
this.wordCH._y -= 5;
this.wordEN._x -= 15;
this.fadeOut = true;
this.fadeIn = false;
}
theItem.onRollOut = function() {
block.sOut = false;
block.sIn = true;
this.wordCH._x += 5;
this.wordCH._y += 5;
this.wordEN._x += 15;
new Color(this.wordCH).setRGB(0x499300);
new Color(this.wordEN).setRGB(0x499300);
this.fadeOut = false;
this.fadeIn = true;
}
theItem.onEnterFrame = function(){
if(this.fadeOut){
if(this.wordCH._xscale<130) {this.wordCH._xscale += 5;this.wordCH._yscale += 5;}
}
if(this.fadeIn){
if(this.wordCH._xscale>100) {this.wordCH._xscale -= 5;this.wordCH._yscale -= 5;}
}
}
theItem.onRelease = function() {
getURL(this.URL);
}
}
//禁止右键菜单
fscommand("showmenu", false);
另外一个菜单源代码
放在main scene frame上
stop();
var m_txt = ["第一章","第二章","第三章","第四章","第五章","第六章","第七章"];
var url_txt = ["PC45.JPG","#","#","#","#","#","PC45.JPG"];
var urls = ["#","#","#","#","#","#","#"];
var temp_url = [];
var myB = false;
var l = m_txt.length;
var temp_n = 0;
for (var i = 0; i<l; i++) {
if (i>0) {
this[i+"_mc"]._x = this[(i-1)+"_mc"]._x+this[(i-1)+"_mc"]._width-1.5;
}
this[i+"_mc"].n = i;
this[i+"_mc"].txt.text = m_txt[i];
this[i+"_mc"].ul = url_txt[i];
this[i+"_mc"].onRollOver = function() {
temp_n = this.n;
this.it.loader.contentPath = this.ul;
myB = true;
var j = 0;
this.onEnterFrame = function() {
j += 20;
this.it._alpha = j;
}
}
this[i+"_mc"].onRelease = function(){
temp_url = urls[this.n];
var url = temp_url;
getURL(url);
}
this[i+"_mc"].onRollOut = function() {
temp_n = this.n;
myB = false;
var j = 100;
this.onEnterFrame = function() {
j = j-20;
this.it._alpha = j-1;
}
}
}
//缓冲效果
var speed = 0;
function move_scale(x, obj) {
speed = (x-obj._xscale)*.1+speed*.20;
obj._xscale += speed;
//obj._yscale = obj._xscale;
}
function move_scale2(x,obj){
obj._xscale -= speed;
}
this.onEnterFrame = function() {
for (var i = 0; i<l; i++) {
this[i+"_mc"]._x = this[(i-1)+"_mc"]._x+this[(i-1)+"_mc"]._width-1.5;
this[i+"_mc"]._x = move_scale(100, this[i+"_mc"]);
}
if (myB) {
var s = 100-10/(l-temp_n+1);
move_scale(200, this[temp_n+"_mc"]);
for (var i = temp_n-1; i>0; i--) {
this[i+"_mc"]._x = move_scale(s, this[i+"_mc"]);
}
} else {
for (var i = temp_n+1; i<l; i++) {
this[i+"_mc"]._x = move_scale2(s, this[i+"_mc"]);
}
}
};
//禁止右键菜单
fscommand("showmenu", false);