Index: lams_flash/src/central/flash/org/lamsfoundation/lams/monitoring/mv/tabviews/LearnerIndexView.as =================================================================== diff -u -rc8a3ab790f64597f8a37e88e5805014136695b16 -r30a0d88e111c90cd5a2e9fc7c4e204551e6061be --- lams_flash/src/central/flash/org/lamsfoundation/lams/monitoring/mv/tabviews/LearnerIndexView.as (.../LearnerIndexView.as) (revision c8a3ab790f64597f8a37e88e5805014136695b16) +++ lams_flash/src/central/flash/org/lamsfoundation/lams/monitoring/mv/tabviews/LearnerIndexView.as (.../LearnerIndexView.as) (revision 30a0d88e111c90cd5a2e9fc7c4e204551e6061be) @@ -82,6 +82,7 @@ private var buttonsShown:Boolean; private var drawButtons:Boolean; // buttons to the right of last index button + private var navigationButtonsDrawn:Boolean; private var direction:String; @@ -97,6 +98,7 @@ nextPosition = 0; btnWidth = 45; buttonsShown = false; + navigationButtonsDrawn = false; drawButtons = true; defaultString = "Enter Page Number"; @@ -176,9 +178,11 @@ } private function newButtonsNeeded(mm:MonitorModel):Boolean { - if ((mm.numIndexButtons > displayedButtons.length) && (displayedButtons.length < mm.numPreferredIndexButtons)) { - mm.updateIndexButtons(); // need to update mm.lastDisplayedIndexButton because it will need to be redrawn - return true; + if (mm.numIndexButtons > displayedButtons.length) { + if (displayedButtons.length < mm.numPreferredIndexButtons || !navigationButtonsDrawn) { + mm.updateIndexButtons(); // need to update mm.lastDisplayedIndexButton because it will need to be redrawn + return true; + } } return false; } @@ -213,11 +217,17 @@ if (drawButtons == true) { _buttonsPanel_mc = this.createEmptyMovieClip("_buttonsPanel_mc", DepthManager.kTop); addRangeLabel(mm); + if (mm.numIndexButtons > mm.numPreferredIndexButtons) { + addBackNavigationButton(mm); + } } addIndexButtons(mm); // if drawButtons = false, just rename labels if (drawButtons == true) { - addNavigationButtons(mm); + if (mm.numIndexButtons > mm.numPreferredIndexButtons) { + addForwardNavigationButton(mm); + navigationButtonsDrawn = true; + } addIndexTextField(mm); addGoButton(mm); @@ -233,13 +243,19 @@ //labelBackground_mc.removeMovieClip(rangeLabel); _buttonsPanel_mc.removeMovieClip(rangeLabel); + + if (mm.numIndexButtons > mm.numPreferredIndexButtons) + _buttonsPanel_mc.removeMovieClip(backBtn); + while (displayedButtons.length != 0) { var idxBtn:MovieClip = MovieClip(displayedButtons.pop()); _buttonsPanel_mc.removeMovieClip(idxBtn); } - - _buttonsPanel_mc.removeMovieClip(backBtn); - _buttonsPanel_mc.removeMovieClip(nextBtn); + + if (mm.numIndexButtons > mm.numPreferredIndexButtons) { + _buttonsPanel_mc.removeMovieClip(nextBtn); + navigationButtonsDrawn = false; + } //need to remove the text field from the background textFieldBackground_mc.removeMovieClip(idxTextField); @@ -259,6 +275,15 @@ nextPosition += rangeLabel._width; } + private function addBackNavigationButton(mm:MonitorModel):Void { + // add back navigation button + backBtn = _buttonsPanel_mc.attachMovie("IndexButton", "backBtn", _buttonsPanel_mc.getNextHighestDepth(), {_width: btnWidth-5, _labelText: "<<"}); + _indexButton = IndexButton(backBtn); + _indexButton.init(mm, undefined); + backBtn._x = nextPosition; + nextPosition += (btnWidth-5); + } + private function addIndexButtons(mm:MonitorModel):Void { // The index buttons Debugger.log("mm.numIndexButtons: "+mm.numIndexButtons, Debugger.GEN, "addIndexButton", "LearnerIndexView"); @@ -284,14 +309,7 @@ } } - private function addNavigationButtons(mm:MonitorModel):Void { - // add navigation buttons - backBtn = _buttonsPanel_mc.attachMovie("IndexButton", "backBtn", _buttonsPanel_mc.getNextHighestDepth(), {_width: btnWidth-5, _labelText: "<<"}); - _indexButton = IndexButton(backBtn); - _indexButton.init(mm, undefined); - backBtn._x = nextPosition; - nextPosition += (btnWidth-5); - + private function addForwardNavigationButton(mm:MonitorModel):Void { nextBtn = _buttonsPanel_mc.attachMovie("IndexButton", "nextBtn", _buttonsPanel_mc.getNextHighestDepth(), {_width: btnWidth-5, _labelText: ">>"}); _indexButton = IndexButton(nextBtn); _indexButton.init(mm, undefined);