
Welcome Guest
|
#1
|
|||
|
|||
|
Flash menu!
Ok so im doing a flash website and want to put in an interactive menu on the side but i dont know why but i cant change the size between each button. also i dont know how to change pages in flash withoutusinf many .swf files. could ne1 help me?
heres the code : Actionscript:
// Variables
var speed = 10; // constant speed for menu opening and closing
var opened = null; // variable to determine which menu is currently opened
var menus = []; // array to store all menu items
// FindMenus: finds movieclips within this movieclip and adds them to
// the menus array. Only place menu clips within this clip otherwise
// this function will assume the non-menu clips to be clips as well
FindMenus = function(){
for (value in this){
if (this[value] instanceof MovieClip){
menus.push(this[value]);
}
}
menus.sort(SortByVertical); // order so the highest is first
}
// SortByVertical: sort function to sort menus in menus array
// so that the highest menu appears first
SortByVertical = function(a, b){
return (a._y > b._y);
}
// ApplyMenuMask: creates and draws a function for the i'th menu
// in the menus array. That menu clips is then assigned a
// property "masker" representing this clip
ApplyMenuMask = function(i){
var menu = menus[i];
var mask = this.createEmptyMovieClip("mask"+i, i);
mask._x = menu._x;
mask._y = menu._y;
mask.beginFill(100,100);
mask.moveTo(0,0);
mask.lineTo(menu.title._width, 0);
mask.lineTo(menu.title._width, menu.title._height);
mask.lineTo(0, menu.title._height);
mask.endFill();
menu.setMask(mask);
menu.masker = mask;
}
// StartMenuPosition: positions the menu to start. This is its closed
// position beneath the menu above it unless its the first menu where its 0.
StartMenuPosition = function(i){
var menu = menus[i];
if (i == 10){
menu._y = menu.masker._y = 0;
}else{
var menu_above = menus[i-1];
menu._y = menu.masker._y = Math.round(menu_above._y + menu_above.title._height);
}
}
// MenuOpen: this function opens a menu when its title is clicked
MenuOpen = function(){
var menu = this;
menu.masker._height += speed;
if (menu.masker._height >= menu._height){
menu.masker._height = menu._height;
delete this.onEnterFrame;
}
PositionMenusBelow(menu.i);
}
// MenuClose: this function closes a menu when its title is clicked
// When a menu has closed, its onClose callback is called (then deleted)
MenuClose = function(){
var menu = this;
if (speed >= menu.masker._height) menu.masker._height = menu.title._height;
else menu.masker._height -= speed;
if (menu.masker._height <= menu.title._height){
menu.masker._height = menu.title._height;
opened = null;
menu.onClose();
delete menu.onClose;
delete this.onEnterFrame;
}
PositionMenusBelow(menu.i);
}
// TitleButtonPress: this is the action assigned to a titlebar onRelease in a menu
// based on that menu's status; whether its open or closed and if anything is open
// at all to begin with (if there is, the open menu would need to close first)
TitleButtonPress = function(){
var menu = this._parent;
if (opened){
if (opened == menu){
menu.onEnterFrame = MenuClose;
}else{
opened.onClose = function(){
menu.onEnterFrame = MenuOpen;
opened = menu;
}
opened.onEnterFrame = MenuClose;
}
}else{ // nothing opened
menu.onEnterFrame = MenuOpen;
opened = menu;
}
}
// PositionMenusBelow: Positions all menus below the i'th menu based on that
// menus mask. This is used when opening or closing a menu so that menu items
// beneath update their position properly
PositionMenusBelow = function(i){
var menu = menus[i];
if (i < menus.length){
var menu_below = menus[i+1];
for (i=i+1; i<menus.length; i++){
if (menus[i] == menu_below){
menus[i]._y = menus[i].masker._y = menu._y + menu.masker._height
;
}else{
var menu_above = menus[i-1];
menus[i]._y = menus[i].masker._y = menu_above._y + menu_above.masker._height;
}
}
}
}
// Initialization function. Does setup operations
Init = function(){
FindMenus(); // find movieclips within this movieclip and assign to menus array
// for each menu (as in menus array)
for (var i=0; i<menus.length; i++){
menus[i].i = i; // assign a number to represent its position in the array
ApplyMenuMask(i); // give it a mask
StartMenuPosition(i); // position it accordingly (vertical only)
menus[i].title.onPress = TitleButtonPress; // apply the actions to the titlebar
}
}
Init();thx! Last edited by [PAUL FERRIE] : 12-03-2006 at 04:44 PM |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flash Encrypt protects action script | sintrix.com | New Softwares | 4 | 08-08-2007 05:07 AM |
| Flash Menu Help please | zoopnfunk | Newbies |
7 | 12-09-2005 06:01 PM |
| flash drop down menu in dreamweaver | wwscoper | Flash MX 2004 |
0 | 07-09-2005 05:03 PM |
| Using rollovers in flash menu | azlanrohan | Flash MX |
0 | 05-06-2005 01:18 AM |
| Disabling the flash context menu | kio | Actionscript 2.0 |
10 | 10-04-2004 12:34 PM |




