获取外部按钮方法【AS2.0】
因为按钮元件的事件除了弹起外没有停止的地方,所以就自己做元件。然后场景中的元件要判断是不是鼠标按到了自己。--就这么简单
制作过程:
1.在场景中画个你喜欢的形状图形作为按钮。选中这个图形按F8转换为影片剪辑元件,进到这个元件里面。在第2贞插入一个关键帧,改变一下颜色(或者形状)。新建一个层。分别在1-2贞stop()
2.在库中右键点这个元件选“链接”,在标识符的后面起个链接名称,我这里的是“FANG”
3.回到主场景。在第一帧写代码:
var zt:Number;
for (i=0; i<7; i++) {
_root.attachMovie("fang","fang"+i,i);
_root["fang"+i]._x = 55+i*45;
_root["fang"+i]._y = Stage.height/2;
_root["fang"+i].sz = i;
_root["fang"+i].onPress = function() {
h = 0;
zt = this.sz;
};
_root["fang"+i].onMouseDown = function() {
this.onEnterFrame = function() {
trace(this.onEnterFrame);
if (this.sz == zt) {
this.gotoAndStop(2);
} else {
this.gotoAndStop(1);
}
};
};
_root["fang"+i].onMouseUp = function() {
delete this.onEnterFrame;
trace(this.onEnterFrame);
};
}
for (i=0; i<7; i++) {
_root.attachMovie("fang","fang"+i,i);
_root["fang"+i]._x = 55+i*45;
_root["fang"+i]._y = Stage.height/2;
_root["fang"+i].sz = i;
_root["fang"+i].onPress = function() {
h = 0;
zt = this.sz;
};
_root["fang"+i].onMouseDown = function() {
this.onEnterFrame = function() {
trace(this.onEnterFrame);
if (this.sz == zt) {
this.gotoAndStop(2);
} else {
this.gotoAndStop(1);
}
};
};
_root["fang"+i].onMouseUp = function() {
delete this.onEnterFrame;
trace(this.onEnterFrame);
};
}
-----------------------------------------------------------------------
补充:flash教程,Action