有朋友PM偶,发现偶公司网站上的A3菜单代码跟原A3的菜单有所不同,其实是因为原来的菜单无法在Flash2004版本下运行,唯有自己编咯。既然有朋友有爱好,我也就把他跟大家分享一下吧~ 先看一下效果先~~
[全屏欣赏]
2004的源文件:
点击浏览该文件MX的源文件:
点击浏览该文件做法可能有点笨,但很轻易理解。究竟偶之AS的菜菜
这是源代码:
stop(); //这是最重要的一段
targetX = 0;
speedX = 0;
MovieClip.prototype.xMove = function(a, b, tx) { //先定义一个函数先~
var tempx = this._x;
this._x = ((a*(this._x-tx))+(b*(this.prevx-tx)))+tx; //这句主要是产生弹性效果
this.prevx = tempx;
}; //初始化参数
tx1 = 0;
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
m1.onEnterFrame = function() { //当命名为m1的按钮加载后马上执行函数
this.xMove(1.5, -0.8, tx1);
};
m2.onEnterFrame = function() { //同上~~
this.xMove(1.5, -0.8, tx2);
};
m3.onEnterFrame = function() {//同上~~
this.xMove(1.5, -0.8, tx3);
};
m4.onEnterFrame = function() {//同上~~
this.xMove(1.5, -0.8, tx4);
};
m5.onEnterFrame = function() {//同上~~
this.xMove(1.5, -0.8, tx5);
};
m6.onEnterFrame = function() {//同上~~
this.xMove(1.5, -0.8, tx6);
};
m7.onEnterFrame = function() {//同上~~
this.xMove(1.5, -0.8, tx7);
};
m1.hit.onRollOver = function() { 当鼠标经过按钮时,其他按钮的动作~
m1.gotoAndStop(2);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 110; //注重这些参数的变化~~~
tx3 = 200;
tx4 = 290;
tx5 = 380;
tx6 = 470;
tx7 = 560;
};
m2.hit.onRollOver = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(2);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 200;
tx4 = 290;
tx5 = 380;
tx6 = 470;
tx7 = 560;
};
m3.hit.onRollOver = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(2);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 290;
tx5 = 380;
tx6 = 470;
tx7 = 560;
};
m4.hit.onRollOver = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(2);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 380;
tx6 = 470;
tx7 = 560;
};
m5.hit.onRollOver = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(2);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 470;
tx7 = 560;
};
m6.hit.onRollOver = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(2);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 560;
};
m7.hit.onRollOver = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(2);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
};
m1.hit.onRollOut = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
};
m2.hit.onRollOut = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
};
m3.hit.onRollOut = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
};
m4.hit.onRollOut = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
};
m5.hit.onRollOut = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
};
m6.hit.onRollOut = function() {
m1.gotoAndStop(1);
m2.gotoAndStop(1);
m3.gotoAndStop(1);
m4.gotoAndStop(1);
m5.gotoAndStop(1);
m6.gotoAndStop(1);
m7.gotoAndStop(1);
tx2 = 90;
tx3 = 180;
tx4 = 270;
tx5 = 360;
tx6 = 450;
tx7 = 540;
};
m1.hit.onRelease = function() { //当按钮被点击释放时,就加载其他MC
loadMovie("v5/about.swf", _root.main_mc);
};
m2.hit.onRelease = function() {
loadMovie("v5/news.swf", _root.main_mc);
};
m3.hit.onRelease = function() {
loadMovie("v5/Portfolio.swf", _root.main_mc);
};
m4.hit.onRelease = function() {
loadMovie("v5/Service.swf", _root.main_mc);
};
m5.hit.onRelease = function() {
loadMovie("v5/Contact.swf", _root.main_mc);
};
m6.hit.onRelease = function() {
loadMovie("v5/gbook/gbook.swf", _root.main_mc);
};
其实这段AS是好简单和轻易理解的,只是我把所有AS都写在第一帧上,所以很长~,其实你可以把他们都写到按钮上(不过就要注重一下路径问题了)