List menu

Code Actionscript 2.0

Frame action

buttons = ["nov", "dec", "jan", "feb"];
for (row = 0; row < buttons.length; row = row + 1) {
square.duplicateMovieClip("square" + row, row);
_root["square" + row]._y = 20 + row * 30;
_root["square" + row].textfield.text = buttons[row];
_root["square" + row].id = row;
}
// hide original
square._visible = 0;

Instance action

on (rollOver) {
this._alpha = 30;
}
on (rollOut) {
this._alpha = 100;
}
on (press) {
// important: movieclips have to be exported for actionscript
// go to "Linkage" in library-menu.
_root.attachMovie("tree" + id, "tree", 99);
_root.tree._x = 210;
}

Code Actionscript 3.0

// important: movieclips tree0 - tree3 have to be exported for actionscript // go to "Linkage" in library-menu. var buttons: Array = ["nov", "dec", "jan", "feb"]; var trees:Array = new Array(); var Squares:Array = new Array(); var pic = null; for (var row = 0; row < buttons.length; row = row + 1){ //important: square has to be exported for actionscript //go to "linkage" in library menu Squares[row] = new squareObject(); Squares[row].x = square.x; Squares[row].y = 20 + row * 30; Squares[row].textfield.text = buttons[row]; Squares[row].id = row; Squares[row].addEventListener(MouseEvent.MOUSE_DOWN, press); Squares[row].addEventListener(MouseEvent.MOUSE_OVER, rollOver); Squares[row].addEventListener(MouseEvent.MOUSE_OUT, rollOut); addChild(Squares[row]); } trees[0] = new tree0(); trees[1] = new tree1(); trees[2]= new tree2(); trees[3] = new tree3(); for (var i=0; i < trees.length; i= i+1) { trees[i].visible = false; addChild(trees[i]); } // hide original square.visible = false; function rollOver(e:MouseEvent) { e.target.alpha = 0.3; } function rollOut(e:MouseEvent) { e.target.alpha = 1; } function press(e:MouseEvent) { if (e.target.name!="textfield") { if (pic != null) { pic.visible = false; } pic = trees[e.target.id]; pic.visible = true; trees[e.target.id].x = 210; } }

Description

This script creates a menu that will access various pictures. For each item in the buttons array, a new copy of square is generated. Each square is labeled according to the values inside of the buttons array. The movieclips in the flash-library have to be 'exported for actionscript', so they can be duplicated by Actionscript.

related to: Lists 2D

Download

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


Share