(working in AS2.0 due to player limitations)
In my flash application I draw in data from an XML. This data is for example 6 lines long in 1 language, but could be 20 in a different language.
However the textbox on the screen can only populate 10 lines of text and I'd like to give the option to users to press the arrows to go to the next page (if there is a next page).
What are my options to get this 'page'-effect?
You can figure out the roundabout total of characters that can fit per page. Then use substring to get the text for each page until you reach the end of the xml string. Put each page string into an array and just change the text in the textfield when the user clicks the arrow using an iterator type pattern.
Edit based on comment:
Ah I see what you are saying. Well here's a more brute force, character-by-character method to creating an array of textfields at or around a specified height.
var pageIndex = 0;
var maxHeight = 300;
var copy = "Some super long chunk of text here";
var pages = [];
function parsePages()
{
for(var i = 0; i < copy.length; i++)
{
if(pages.length == 0) createPage(0);
pages[pageIndex].text += copy.charAt(i);
pages[pageIndex]._height = pages[pageIndex].textHeight;
if(pages[pageIndex]._height >= maxHeight)
{
pageIndex++;
createPage(pageIndex);
}
}
}
function createPage(index)
{
this.createTextField("page_"+index,this.getNextHighestDepth(),0,0,300,12);
this["page_"+index].multiline = true;
this["page_"+index].wordWrap = true;
this["page_"+index].font = "Arial";
this["page_"+index].size = 10;
this["page_"+index].text = "";
pages.push(this["page_"+index]);
}
parsePages();