# Setting Visibility for Next/Prev Buttons

**URL:** <https://forum.kirupa.com/t/setting-visibility-for-next-prev-buttons/221147>\
**Category:** flash\
**Created:** [April 1, 2007, 11:04pm UTC](https://forum.kirupa.com/t/setting-visibility-for-next-prev-buttons/221147 "2007-04-01T23:04:18Z")\
**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 1, 2007, 11:04pm UTC](https://forum.kirupa.com/t/setting-visibility-for-next-prev-buttons/221147/1 "2007-04-01T23:04:18Z")

</div>

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

//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 creating a buttonVisibility function but I’m doing something wrong because it either turns one or the other button off completely. Any help would be greatly appreciate. Thank you in advance.
