Comunidad de diseño web y desarrollo en internet online

menu tipo arbol dinamico

Citar            
MensajeEscrito el 05 Dic 2007 07:17 pm
me han pasado el siguiente codigo que es de un menu complejisimo y no se como hacer que cada uno de los botones del menu me cargue un swf distinto. ¿alguien puede ayudarme?




// set template not visible
_root.MenuTemplate._visible = 0;

// set initial Name and Depth Index
MenuNameIndex = 0;
_root.greatestDepth = 0

// define MenuItem count and clickedNamefor clickUp and clickDown actions
_root.menuCount = 0
_root.clicked = ""
_root.numItems = 0

// define MenuDef class
function MenuDef (MenuDefString) {
this.index = 1;
this.MenuString = MenuDefString;
this.token = "";
}
// define MenuDef methods: getNextToken and peekNextToken
MenuDef.prototype.getNextToken = function () {

if ( this.index < length ( this.MenuString ) ) {
nextChar = substring(this.MenuString, this.index, 1);

if (nextChar == "(") {
this.index += 1;
this.token = nextchar;
return this.token;
}
else if (nextChar == ")") {
this.index += 1;
this.token = nextchar;
return this.token;
}
else if (nextChar == ",") {
this.index += 1;
this.token = nextchar;
return this.token;
}
else {
this.token = "";
while (nextChar != "(" and nextChar != ")" and nextChar!= ",") {
this.token = this.token + nextChar;
this.index += 1;
nextChar = substring(this.MenuString, this.index, 1);
}

return this.token;
}
}
else {
return "";
}
};

MenuDef.prototype.peekNextToken = function () {

if ( this.index < length ( this.MenuString ) ) {
nextChar = substring(this.MenuString, this.index, 1);

if (nextChar == "(") {
this.oldindex = this.index;
this.index += 1;
this.token = nextchar;
this.index = this.oldindex;
return this.token;
}
else if (nextChar == ")") {
this.oldindex = this.index;
this.index += 1;
this.token = nextchar;
this.index = this.oldindex;
return this.token;
}
else if (nextChar == ",") {
this.oldindex = this.index;
this.index += 1;
this.token = nextchar;
this.index = this.oldindex;
return this.token;
}
else if (nextChar != "(" and nextChar != ")" and nextChar != ",") {

this.oldindex = this.index;
this.token = "";

while (nextChar != "(" and nextChar != ")" and nextChar != ",") {
this.token = this.token + nextChar;
this.index += 1;
nextChar = substring(this.MenuString, this.index, 1);
}

this.index = this.oldindex;

return this.token;
}
}
else {
return "";
}
}

// create MenuStructure object with definition
_root.MenuStructure = new MenuDef("This(Menu(is,the(most,complex,menu)),that,has(yet,been,put(in)))");


// define Menu function for creating logical Menu

function Menu (parent, prevBro, MenuDepthIndex) {

// Get the new menu item number
MenuNameIndex += 1;

// get next token value
var token = _root.MenuStructure.getNextToken();

// creates MenuItem movieclip
duplicateMovieClip (_root.MenuTemplate, "MenuItem"+MenuNameIndex, MenuNameIndex);

// setup MenuItem initial values
var ThisMenu = _root["MenuItem" + MenuNameIndex];
ThisMenu.parent = parent;
ThisMenu.followBro = null;
ThisMenu.prevBro = prevBro;
ThisMenu.child = null;
ThisMenu._visible = false ;
ThisMenu.menuNumber = MenuNameIndex;
ThisMenu.LevelText.Leveltext = token;
ThisMenu.dirLine._visible = false
ThisMenu.depth = MenuDepthIndex

// peeks following token
var peektoken = _root.MenuStructure.peekNextToken();

// creates next child
if (peektoken == "(") {
token = _root.MenuStructure.getNextToken(); // Sink "("
ThisMenu.child = Menu(ThisMenu, null,MenuDepthIndex+1);
token = _root.MenuStructure.getNextToken(); // Sink ")"
}

// peeks following token
peektoken = _root.MenuStructure.peekNextToken();

// creates following brother
if (peektoken == ",") {
token = _root.MenuStructure.getNextToken(); // Sink ","
ThisMenu.followBro = Menu (parent, ThisMenu,MenuDepthIndex);
}

// sets button text
if (ThisMenu.child == null) {
ThisMenu.LevelButton.Buttontext = "-"
} else {
ThisMenu.LevelButton.Buttontext = "+"
}

//set number of Items
_root.numItems = MenuNameIndex

//returns MenuNumber
return ThisMenu;
}

function setCoords (node) {
if (node != null) {
node._x = 600;
node._y = 450;
setCoords (node.child);
setCoords (node.followBro);
}
}


// create Menu Object and first MenuItem visible

Menu (null,null,0);
setCoords (_root.MenuItem1)
_root.MenuItem1._x = 330
_root.MenuItem1._y = 355
_root.MenuItem1._visible = 1
_root.MenuItem1.openBrothers (1)
_root.MenuItem1.visibleBrothers ()


stop();

Por vix

1 de clabLevel



 

msie7
Citar            
MensajeEscrito el 06 Dic 2007 07:48 pm
MenuItem1.onRelease=function{ loadMovie("peli1.swf",cargador);}

MenuItem2.onRelease=function{ loadMovie("peli2.swf",cargador);}

etc...

Por clipdepelicula

237 de clabLevel



 

Valencia (España)

firefox
Citar            
MensajeEscrito el 07 Dic 2007 12:18 pm
gracias, lo he probado y me da el siguiente error:

**Error** Escena=Scene 1, capa=Actions and Labels, fotograma=1:Línea 185: Se espera nombre de función
MenuItem1.onRelease=function{ loadMovie("peli1.swf",cargador);}

**Error** Escena=Scene 1, capa=Actions and Labels, fotograma=1:Línea 187: Se espera nombre de función
MenuItem2.onRelease=function{ loadMovie("peli2.swf",cargador);}

que tengo que hacer?

Por vix

1 de clabLevel



 

msie7
Citar            
MensajeEscrito el 07 Dic 2007 12:33 pm
te faltan los parentesis

MenuItem1.onRelease=function () { loadMovie("peli1.swf","cargador");}

MenuItem2.onRelease=function () { loadMovie("peli2.swf","cargador");}

Por egoman

61 de clabLevel



Genero:Masculino  

Concepción - Chile!

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.