Flash+XML写了个类似韩国菜单的效果
类别: Flash教程
预览效果:http://www.vbobo.com/teach/krmenu/
因为这次这个效果是公司的任务,我也是顺便共享出来给大家,希望给新手一些帮助,不过我并没有写出注释,希望需要的人自己能分析下,语法不算复杂!
AS代码如下:
stop();
System.useCodepage = true;
Stage.scaleMode = "noScale";
Stage.showMenu = false;
Stage.align = "T";
var mxml:XML = new XML();
mxml.ignoreWhite = true;
mxml.load("MenuList.xml");
var pageID:Number = 0;
mxml.onLoad = function(success) {
if (!success) {
trace("XML文件装载失败!");
} else {
menuList = mxml.firstChild.childNodes;
InitMenu();
}
};
function InitMenu() {
createEmptyMovieClip("myMenu", -1);
myMenu._y = 263;
myMenu.onEnterFrame = InitMenuX;
MLN = menuList.length;
for (i=0; i<MLN; i++) {
loads = createEmptyMovieClip("loadx"+i, i);
loads.loadMovie(menuList[i].attributes.swf);
loads._xscale = loads._yscale=0;
loads._visible = false;
menus = myMenu.attachMovie("menu", "menu"+i, i);
menus.menu_box._visible = false;
menus.menu_box._xscale = 1;
menus.MName.text = menuList[i].attributes.name;
menus.id = i;
menus.onRollOver = menuOver;
menus.onRelease = menuRelease;
}
myMenu["menu"+pageID].onEnterFrame = menuOver;
}
function InitCMenu(cmenuMC) {
createEmptyMovieClip("CMenu", -2);
myMC = cmenuMC;
CMenu._y = -50;
CMenu.onEnterFrame = InitCMenuX;
cmenuList = menuList[cmenuMC.id].childNodes;
CLL = cmenuList.length;
for (i=0; i<CLL; i++) {
cmenus = CMenu.attachMovie("cmenu", "cmenu"+i, i);
cmenus.CMenu.text = cmenuList[i].attributes.name;
cmenus.id = i;
cmenus.onRelease = function() {
getURL(cmenuList[this.id].attributes.url);
};
}
}
function menuOver() {
menu_box_fun(this);
this.loadICon.loadMovie(menuList[this.id].attributes.swf);
this.loadICon._x = 7;
this.loadICon._alpha = 0;
this.onEnterFrame = function() {
if (this.loadICon._height != 0) {
this.loadICon._y = (this.menu_box._y+this.menu_box._height)-this.loadICon._height;
if(this.loadICon._alpha<100){
this.loadICon._alpha += 4.5;
}else{
delete this.onEnterFrame;
}
}
};
my_color = new Color(this.MName);
my_color.setRGB(0xffffff);
InitCMenu(this);
}
function menuRelease() {
getURL(menuList[this.id].attributes.url);
}
function menu_box_fun(thisMC) {
for (i=0; i<MLN; i++) {
menus = myMenu["menu"+i];
if (menus == thisMC) {
menus.menu_box._visible = true;
menus.menu_box._xscale = 100;
} else {
menus.loadICon.unloadMovie();
menus.menu_box._visible = false;
menus.menu_box._xscale = 1;
my_color = new Color(menus.MName);
my_color.setRGB(0xF3D686);
}
}
}
function InitMenuX() {
for (i=0; i<MLN; i++) {
menus = myMenu["menu"+i];
mmbv = menus.menu_box._visible;
menus.MName._x += mmbv == true ? (60-menus.MName._x)*0.2 : (0-menus.MName._x)*0.2;
menux = myMenu["menu"+(i-1)];
menuXW = menux._x+menux._width;
menus._x += (menuXW-menus._x)*0.2;
}
myMenu._x += ((flash_box._width-(myMenu._width+10))-myMenu._x)*0.2;
}
function InitCMenuX() {
f
or (i=0; i<CLL; i++) {
cmenus = CMenu["cmenu"+i];
cmenux = CMenu["cmenu"+(i-1)];
cmenuXW = cmenux._x+cmenux._width;
cmenus._x += (cmenuXW-cmenus._x)*0.2;
}
myX = myMC.MName._x+myMC._x+myMenu._x;
CMenu._x = myX+CMenu._width>1000 ? 1000-CMenu._width : myX;
CMenu._y = myMenu._y+41;
}
System.useCodepage = true;
Stage.scaleMode = "noScale";
Stage.showMenu = false;
Stage.align = "T";
var mxml:XML = new XML();
mxml.ignoreWhite = true;
mxml.load("MenuList.xml");
var pageID:Number = 0;
mxml.onLoad = function(success) {
if (!success) {
trace("XML文件装载失败!");
} else {
menuList = mxml.firstChild.childNodes;
InitMenu();
}
};
function InitMenu() {
createEmptyMovieClip("myMenu", -1);
myMenu._y = 263;
myMenu.onEnterFrame = InitMenuX;
MLN = menuList.length;
for (i=0; i<MLN; i++) {
loads = createEmptyMovieClip("loadx"+i, i);
loads.loadMovie(menuList[i].attributes.swf);
loads._xscale = loads._yscale=0;
loads._visible = false;
menus = myMenu.attachMovie("menu", "menu"+i, i);
menus.menu_box._visible = false;
menus.menu_box._xscale = 1;
menus.MName.text = menuList[i].attributes.name;
menus.id = i;
menus.onRollOver = menuOver;
menus.onRelease = menuRelease;
}
myMenu["menu"+pageID].onEnterFrame = menuOver;
}
function InitCMenu(cmenuMC) {
createEmptyMovieClip("CMenu", -2);
myMC = cmenuMC;
CMenu._y = -50;
CMenu.onEnterFrame = InitCMenuX;
cmenuList = menuList[cmenuMC.id].childNodes;
CLL = cmenuList.length;
for (i=0; i<CLL; i++) {
cmenus = CMenu.attachMovie("cmenu", "cmenu"+i, i);
cmenus.CMenu.text = cmenuList[i].attributes.name;
cmenus.id = i;
cmenus.onRelease = function() {
getURL(cmenuList[this.id].attributes.url);
};
}
}
function menuOver() {
menu_box_fun(this);
this.loadICon.loadMovie(menuList[this.id].attributes.swf);
this.loadICon._x = 7;
this.loadICon._alpha = 0;
this.onEnterFrame = function() {
if (this.loadICon._height != 0) {
this.loadICon._y = (this.menu_box._y+this.menu_box._height)-this.loadICon._height;
if(this.loadICon._alpha<100){
this.loadICon._alpha += 4.5;
}else{
delete this.onEnterFrame;
}
}
};
my_color = new Color(this.MName);
my_color.setRGB(0xffffff);
InitCMenu(this);
}
function menuRelease() {
getURL(menuList[this.id].attributes.url);
}
function menu_box_fun(thisMC) {
for (i=0; i<MLN; i++) {
menus = myMenu["menu"+i];
if (menus == thisMC) {
menus.menu_box._visible = true;
menus.menu_box._xscale = 100;
} else {
menus.loadICon.unloadMovie();
menus.menu_box._visible = false;
menus.menu_box._xscale = 1;
my_color = new Color(menus.MName);
my_color.setRGB(0xF3D686);
}
}
}
function InitMenuX() {
for (i=0; i<MLN; i++) {
menus = myMenu["menu"+i];
mmbv = menus.menu_box._visible;
menus.MName._x += mmbv == true ? (60-menus.MName._x)*0.2 : (0-menus.MName._x)*0.2;
menux = myMenu["menu"+(i-1)];
menuXW = menux._x+menux._width;
menus._x += (menuXW-menus._x)*0.2;
}
myMenu._x += ((flash_box._width-(myMenu._width+10))-myMenu._x)*0.2;
}
function InitCMenuX() {
f
or (i=0; i<CLL; i++) {
cmenus = CMenu["cmenu"+i];
cmenux = CMenu["cmenu"+(i-1)];
cmenuXW = cmenux._x+cmenux._width;
cmenus._x += (cmenuXW-cmenus._x)*0.2;
}
myX = myMC.MName._x+myMC._x+myMenu._x;
CMenu._x = myX+CMenu._width>1000 ? 1000-CMenu._width : myX;
CMenu._y = myMenu._y+41;
}
- 上一篇: 加载外部图片的百叶窗效果
- 下一篇: Flash页面参数详解
-= 资 源 教 程 =-
文 章 搜 索