I am stuck on the event handler aspect of Javascript.
rowCells[j] is a reference to a unique object. galleryCell is also a reference to newly created object. It stands to reason that the two could link together.
However, it does not seem that the two references get bound together at all for the event listener to work properly. All cells get assigned to the same exact thing (the last galleryCell object).
The galleryCell variable is inside a for-loop getting a new reference at each iteration. Why are these references being lost ?
function TypeGallery (galleryObj)
{ //receives the <div> element that contains rows and cells of a gallery
//Properties --------------
var galleryCellArr = []; //array of galleryZoomCell objects
//Methods -----------------
var Initialize = function ()
{
var rows = galleryObj.children;
var rowCount = rows.length;
for (var i=0;i<rowCount;i++)
{
var rowCells = rows[i].children;
var rowCellCount = rowCells.length;
for (var j=0;j<rowCellCount;j++)
{
var sliderObj = new TypeSlider(300,1,false);
var galleryCell = new TypeGalleryZoomCell(rowCells[j],sliderObj)
galleryCellArr.push(galleryCell);
rowCells[j].onmousedown = function () {galleryCell.Deploy();};
rowCells[j].onmouseup = function () {galleryCell.Retract();};
}
}
}
//Initialization
Initialize();
}