From: <to...@ma...> - 2004-04-01 14:33:59
|
Hya, I'm having some problems here, this is what I wanted to do, but the mouse events don't work. When I put the mouse over the layers I got botao[...] is null or not an object. Whell here is the code: ( menus[] is an outside var that has the text for the menus and other stuff but the prob isn't here ) botao=[]; for (var i=0;i<8;i++) { botao[i] = principal.addChild(new DynLayer(null,19,130,112,25,null,true,2)); botao[i].setClass ('cssmenu'); botao[i].setHTML(menus[i][0]); objStacker.add(botao[i]); var el = { onmouseover : function(e) { botao[i].setClass ('cssmenu2'); botao[i].slideTo(botao[i].getX(),botao[i].getY()-5); botao[i].setWidth(112); botao[i].setHeight(40); }, onmouseout : function(e) { botao[i].slideTo(botao[i].getX(),botao[i].getY()+5); botao[i].setWidth(112); botao[i].setHeight(25); botao[i].setClass ('cssmenu'); }, onclick : function(e) { alert ('click!'); } }; botao[i].addEventListener(el); } if I cut the mouse event and put it outside the for I get the same error, but if I add the events manually, first botao[0], then botao[1] and so on it works, but since I'm doing the same effect on all layers I wanted to add then on all layers at once. What I'm doing wrong here? Thanx, To' This works: botao=[]; for (var i=0;i<8;i++) { botao[i] = principal.addChild(new DynLayer(null,19,130,112,25,null,true,2)); botao[i].setClass ('cssmenu'); botao[i].setHTML('<table border=0 width="100%" height="100%"><tr valign="middle"><td class="one" valign="middle" align="center">'+menus[i][0]+'</td></tr></table>'); objStacker.add(botao[i]); } var el = { onmouseover : function(e) { botao[0].setClass ('cssmenu2'); botao[0].slideTo(botao[0].getX(),botao[0].getY()-5); botao[0].setWidth(112); botao[0].setHeight(40); }, onmouseout : function(e) { botao[0].slideTo(botao[1].getX(),botao[0].getY()+5); botao[0].setWidth(112); botao[0].setHeight(25); botao[0].setClass ('cssmenu'); }, onclick : function(e) { alert ('click!'); } }; botao[0].addEventListener(el); ( same for botao[1], and so on... ) |