It's most likely a dumb little bug, but I need someone else to look over it.
Here's my test swf so you can see the problem: http://www.interactivelab.com.ar/xmlTest /loadingXMLTest.swf
Click from the bottom up and you'll see that the two last work fine, but the 1st and 2nd(from the top) step over each other.
And here's all the relevant code:
for (var i:int = 0; i < _mainXML.alquiler.departamento.unambiente.depto.length(); i++) {
var newBar:itemBar = new itemBar();
newBar.x = 0;
newBar.y = _barCount*((newBar.height - newBar.description_bar.height)+5);
newBar.description_bar.alpha = 0;
itemHolder.addChild(newBar);
newBar.name = String(i);
newBar.minimumY = newBar.y;
newBar.maximumY = newBar.y + newBar.description_bar.height;
_itemArray.push(newBar);
newBar.itemNumber = _barCount;
_barCount++;
_numberTabsClosed = _barCount;
newBar.barrio_txt.mouseEnabled = false;
newBar.nombre_txt.mouseEnabled = false;
newBar.description_bar.direccion_txt.mouseEnabled = false;
newBar.barrio_txt.htmlText = _mainXML.alquiler.departamento.unambiente.depto[i].localidad.toString();
newBar.nombre_txt.htmlText = _mainXML.alquiler.departamento.unambiente.depto[i].nombre.toString();
newBar.description_bar.direccion_txt.htmlText = _mainXML.alquiler.departamento.unambiente.depto[i].direccion.toString();
newBar.buttonMode = true;
newBar.useHandCursor = true;
newBar.addEventListener(MouseEvent.MOUSE_UP, expandInfo);
newBar.description_bar.moreInfo_btn.addEventListener(MouseEvent.MOUSE_UP, loadFicha);
}
...
function expandInfo(e:MouseEvent):void {
if (e.target is itemBar) {
if (!e.target.currentlyOpen) {
_numberTabsOpen++;
_numberTabsClosed--;
TweenMax.to(e.target.description_bar, .3, { alpha:1, onStart:SwitchStates, onStartParams:[e.target] } );
}else {
_numberTabsOpen--;
_numberTabsClosed++;
TweenMax.to(e.target.description_bar, .5, { alpha:0, onStart:SwitchStates, onStartParams:[e.target]} );
}
}
}
function SwitchStates(mc:*) {
mc.currentlyOpen = !mc.currentlyOpen;
moveThingsDown(mc);
}
function moveThingsDown(target:*):void {
var currentItem:int = target.itemNumber;
if (currentItem < 1) {
currentItem = 1;
}
for (var i:uint = currentItem; i < _itemArray.length; i++) {
if (_itemArray[i - 1].currentlyOpen) {
_itemArray[i].y = _itemArray[i].maximumY;
}else {
_itemArray[i].y = _itemArray[i].minimumY;
}
output_txt.appendText("\nCurrent _itemArray[" + String(i) + "].name is: " + _itemArray[i].name +" and it's open state is: "+_itemArray[i].currentlyOpen);
output_txt.appendText("\nPrevious _itemArray[" + String(i-1) + "].name is: " + _itemArray[i-1].name +" and it's open state is: "+_itemArray[i-1].currentlyOpen);
output_txt.appendText("\n ---------------------------------------");
}
}
I'm trying to keep it simple and dynamic, meaning that I can add "x" number of items and it would still work without hard-coding it.
I'm storing the minimum and maximum y values into each item as they are made with this:
newBar.y = _barCount*((newBar.height - newBar.description_bar.height)+5);
...
newBar.minimumY = newBar.y;
newBar.maximumY = newBar.y + newBar.description_bar.height;
So, ideas? It's most likely in the last bit. In the "moveThingsDown" function.