///////////////////IMPORTANT///////////////////////////////////
///You have to insert the corresponding frame for each Layer///
///////////////////////////////////////////////////////////////
//VARIABLES
var Sentences:Array = [];
var Layer = 0;
var Quantity:Number = 6; //Number of sentences in the text file
//INIT
stop();
mainText.text = "Layer "+Layer;
//FUNCTIONS
//Load sentences from text file
myData = new LoadVars();
myData.onLoad = function(Success:Boolean)
{
if(Success)
{
//Loop through all the sentences in the text file
//and push/insert them into the Sentences array/list
for(var i:Number = 0; i < Quantity; i++)
{
Sentences.push(this["content"+i]);
}
//Display the corresponding text in myText_txt textfield
//from the sentences array
myText_txt.text = Sentences[Layer];
}
};
myData.load("example1.txt");
//Check to hide or show the previous and next buttons depending on data
function hideButtons()
{
//If the current Layer is not the first one, not the last one
if(Layer > 0 && Layer < Sentences.length - 1)
{
//Then show both buttons
but_prev._visible = true;
but_next._visible = true;
}
//Or if the current Layer is the last one
else if(Layer > 0 && Layer >= Sentences.length - 1)
{
//Hide the previous button, show the next button
but_prev._visible = true;
but_next._visible = false;
}
//Otherwise,
else
{
//Show the next button and hide the previous button
but_prev._visible = false;
but_next._visible = true;
}
}
hideButtons();
//BUTTONS
//Next button
but_next.onPress = function()
{
//Increase the Layer number each time the Next button is pressed
Layer++;
//Call hideButtons
hideButtons();
//Go to the next frame
//nextFrame();
//Display the Layer number in the mainText textfield
mainText.text = "Layer "+Layer;
//Display the corresponding text from the sentences array in the
//myText_txt textfield
myText_txt.text = Sentences[Layer];
}
//Previous button
but_prev.onPress = function()
{
//Increase the Layer number each time the Next button is pressed
Layer--;
//Call hideButtons
hideButtons();
//Go to the next frame
//prevFrame();
//Display the Layer number in the mainText textfield
mainText.text = "Layer "+Layer;
//Display the corresponding text from the sentences array in the
//myText_txt textfield
myText_txt.text = Sentences[Layer];
}