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

Listen Menu

Code Actionscript 2.0

Frame-Aktion

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;

Instanz-Aktion

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; } }

Infos

Dieses Skript erzeugt ein Menu, mit dem verschiedene Bilder geladen werden. Für jeden Eintrag im Array buttons wird eine Kopie des Quadrates square angelegt. Jedes Quadrat wird gemäss dem Array buttons beschriftet. Die Movieclips in der Bibliothek müssen für Actionscript exportiert werden, damit sie von Actionscript dupliziert werden können.

verwandt mit: Listen 2D

Download

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


Share