2005-05-14 15:47 Apple --MAC選單製作教學--
前些日子給一個基金會作圖書館管理的小系統, 好幾天想不出來要製作哪種選單,
有天去台北逛街, 看到一台MAC電腦裡頭的選單很漂亮,
回家後就心血來潮想說用Flash模擬Apple電腦裡頭的選單試試看,
做完後看效過還蠻逼真的. 我將code貼在下方跟大家交流:
class MacMenu extends MovieClip {
function MacMenu() {
loopClip();
setScale();
}
function onLoad() {
}
private function loopClip() {
this.onEnterFrame = function() {
this.clip0._x = this.clip0._width/2;
for (var i = 1; i<10; i++) {
this['clip'+i]._x = this['clip'+(i-1)]._x+this['clip'+(i-1)]._width/2+this['clip'+i]._width/2-1;
}
this._x = 510-this._width/2;
};
}
private function setScale() {
var temp_ar = ['借書處理', '還書處理', '搜尋書目', '搜尋讀者', '開啟書目列表', '開啟讀者列表',
'修改此書目資料', '修改此讀者資料', '開啟列印選單', '設定'];
for (var i = 0; i<10; i++) {
var temp = this['clip'+i];
temp['b'+i].onRollOver = function() {
with (_root) {
fitting = true;
menubar._x = _xmouse;
menubar._y = _ymouse;
menubar._visible = true;
menubar.startDrag();
menubar.menu_txt.text = temp_ar[this._name.substr(1, 1)];
}
};
temp['b'+i].onRollOut = function() {
with (_root) {
fitting = false;
menubar.stopDrag();
menubar._visible = false;
}
};
temp.onEnterFrame = function() {
var distance = Math.sqrt(Math.pow(_parent._xmouse-this._x, 2)+Math.pow(_parent._ymouse-this._y, 2));
if (_root.fitting) {
var width = 100-distance/2;
if (width<=30)width = 30;
this._width += (width-this._width)/3;
this._height = this._width;
} else {
this._width += (30-this._width)/4;
this._height = this._width;
}
};
}
}
}


