NEU: Alle Visual Codes als Code Snippets für Flash CS5:
jetzt hier downloaden .

Dropdown Menus mit Inhalt

Code Actionscript 2.0

Frame-Aktion

option = ["File", "Edit", "View", "Insert"];
suboption = [[]];
suboption[1] = ["New", "Open", "Close", "Save", "Save As ", "Quit"];
suboption[2] = ["Undo", "Select All", "Find"];
suboption[3] = ["Zoom In", "Zoom Out", "Actual Size", "New View"];
suboption[4] = ["New Symbol", "Text Field"];
for (column = 0; column < option.length; column = column + 1) {
mainmenu.duplicateMovieClip("menu" + column, column);
_root["menu" + column]._x = 4 + column * 98;
_root["menu" + column]._y = 4;
_root["menu" + column].textfield.text = option[column];
_root["menu" + column].id = column + 1;
}
mainmenu._visible = 0;

Instanz-Aktion mainmenu

onClipEvent (load) {
this._alpha = 100;
}
on (rollOver) {
this._alpha = 30;
}
on (rollOut) {
this._alpha = 100;
}
on (press) {
i = 0;
for (row = 0; row < _root.suboption[id].length; row = row + 1) {
i = i + 1;
_root.submenu.duplicateMovieClip("sub" + row, i + 100);
_root["sub" + row]._y = this._y + 20 + row * 20;
_root["sub" + row]._x = this._x;
_root["sub" + row].textfield.text = _root.suboption[id][row];
}
for (rest = i; rest < 40; rest = rest + 1) {
_root["sub" + rest].unloadMovie();
}
}

Instanz-Aktion submenu

onClipEvent (load) {
this._alpha = 100;
}
on (rollOver) {
this._alpha = 30;
}
on (rollOut) {
this._alpha = 100;
}
on (press) {
}

Code Actionscript 3.0

var option:Array = ["File", "Edit", "View", "Insert"]; var suboption:Array = new Array(); suboption[1] = ["New", "Open", "Close", "Save", "Save As ", "Quit"]; suboption[2] = ["Undo", "Select All", "Find"]; suboption[3] = ["Zoom In", "Zoom Out", "Actual Size", "New View"]; suboption[4] = ["New Symbol", "Text Field"]; var mainmenus:Array = new Array(); var submenus:Array = new Array(); var myformat = new TextFormat(); myformat.font = "Font1"; // font must be embedded and exported for Actionscript for (var column=0; column < option.length; column=column+1) { mainmenus[column] = new mainmenuObject(); mainmenus[column].x = 4+column*98; mainmenus[column].y = 4; mainmenus[column].textfield.embedFonts = true; mainmenus[column].textfield.setTextFormat(myformat); mainmenus[column].textfield.text = option[column]; mainmenus[column].id = column+1; mainmenus[column].alpha = 1; mainmenus[column].visible= true; mainmenus[column].addEventListener(MouseEvent.MOUSE_OVER, rollOver); mainmenus[column].addEventListener(MouseEvent.MOUSE_OUT, rollOut); mainmenus[column].addEventListener(MouseEvent.MOUSE_DOWN, press); this.addChild(mainmenus[column]); } for (column=0; column < option.length; column=column+1) { submenus[column]= new Array(); for (var row=0; row < suboption[column+1].length; row=row+1) { var i = i+1; submenus[column][row] = new submenuObject(); submenus[column][row].y = mainmenus[column].y+20+row*20; submenus[column][row].x = mainmenus[column].x; submenus[column][row].textfield.text =suboption[column+1][row]; submenus[column][row].visible = false; submenus[column][row].addEventListener(MouseEvent.MOUSE_OVER, rollOver); submenus[column][row].addEventListener(MouseEvent.MOUSE_OUT, rollOut); this.addChild(submenus[column][row]); } } mainmenu.visible = false; function rollOver(e:MouseEvent) { e.target.alpha = 0.3; } function rollOut(e:MouseEvent) { e.target.alpha = 1; } function press(e:MouseEvent) { for (column = 0; column < mainmenus.length; column = column+1) for(row = 0; row < submenus[column].length; row = row+1) submenus[column][row].visible= false; for (row=0; row < suboption[e.target.parent.id].length; row=row+1) { submenus[e.target.parent.id-1][row].visible = true; } }

Infos

Ein Menu mit Dropdown-Untermenus. Der 2D-Array suboption enthält für jeden Eintrag des Hauptmenus alle Untermenu-Einträge. In Actionscript 2 legt die Frame-Aktion das Hauptmenu an und beschriftet es. Die Instanz-Aktion von mainmenu erzeugt und beschriftet die Untermenus. In Actionscript 3 erzeugen zwei Schleifen das Hauptmenu und die zugehörigen Untermenus.

verwandt mit: Dropdown Menus,

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share