# Previous Button Invisible On First Page

**URL:** <https://forum.kirupa.com/t/previous-button-invisible-on-first-page/221202>\
**Category:** flash\
**Created:** [April 2, 2007, 2:10pm UTC](https://forum.kirupa.com/t/previous-button-invisible-on-first-page/221202 "2007-04-02T14:10:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zarahs](https://avatars.discourse-cdn.com/v4/letter/z/ed8c4c/32.png) [@Zarahs](https://forum.kirupa.com/u/Zarahs)\
**Post date:** [April 2, 2007, 2:10pm UTC](https://forum.kirupa.com/t/previous-button-invisible-on-first-page/221202/1 "2007-04-02T14:10:26Z")

</div>

I have several pages of info I’m pulling from external txt files. I want my btn\_previous to not be visible on the first page. Likewise, I want my btn\_next to not be visible when the last page loads. The btns are actually moviclips with instance names btn\_next and btn\_prev Here is my code, so far:

//Stage Scale  
Stage.scaleMode = “exactFit”;  
width\_txt.text = Stage.width;  
height\_txt.text = Stage.height;  
// End Stage Scale

//Stage Resize Listener  
var resizeListener:Object = new Object();  
resizeListener.onResize = function()  
{  
width\_txt.text = Stage.width;  
height\_txt.text = Stage.height;  
}  
Stage.addListener(resizeListener);  
// End Stage Resize Listener

// Default Page Number Variable  
var currrentPage:Number = 0;

// Movie Clip Variable  
var myMCL:MovieClipLoader = new MovieClipLoader();

// Total Pages Var and Load  
var myPageTotal:LoadVars = new LoadVars();  
myPageTotal.load(“pages/pageTotal.txt”);

//Pages Var  
var infoPageTotal:LoadVars = new LoadVars();

// Page Counter Function  
function pageCounter():Void  
{  
txt\_pageNumber.text = (currrentPage + 1) + " / " + Number(myPageTotal.totalPages);  
}  
myPageTotal.onLoad = function(p\_success:Boolean):Void  
{  
if(p\_success)  
{  
pageCounter();  
}  
else  
{  
txt\_pageNumber.text = “Error loading file.”;  
}  
}  
// End Page Counter Function

// Next Page Function  
function nextPage(){  
infoPageTotal.load(“pages/page” + currrentPage + “.txt”);  
infoPageTotal.onLoad = function(p\_success:Boolean):Void  
{  
if(p\_success)  
{  
txt\_page.htmlText = infoPageTotal.info;  
}  
else  
{  
txt\_page.text = “Error loading file.”;  
}  
}  
}  
nextPage();  
// End Next Page Function

// Next Button Actions  
btn\_next.onRelease = function():Void  
{  
if(currrentPage \< Number(myPageTotal.totalPages) - 1)  
{  
currrentPage ++;  
gotoAndPlay(2);  
}  
else  
{  
currrentPage = 0;  
}  
nextPage();  
pageCounter();  
}  
// End Next Button Actions  
// Previous Button Actions  
btn\_prev.onRelease = function():Void  
{  
if(currrentPage == 0)  
{  
currrentPage = Number(myPageTotal.totalPages) - 1;  
}  
else  
{  
currrentPage --;  
gotoAndPlay(6);  
}  
nextPage();  
pageCounter();  
}  
// End Previous Button Actions  
stop();

I’ve tried variations of btn\_next.\_visible = false; but I end up with one or the other buttons invisible all the time and then I can’t navigate at all. With the buttons on all the time you can click either button and cycle endlessly through the various pages, which isn’t what I want to happen. Any help, or advice, would be greatly appreciated. Thank you in advance for your help.
