Created
March 1, 2011 08:51
-
-
Save chromeragnarok/848849 to your computer and use it in GitHub Desktop.
a bit of the recursive function for paging. caution, this is not the full code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generatePaging(fetchSize:Number=128):void | |
{ | |
var buffer:Array = new Array(); | |
var i:Number = 0; | |
while (i < fetchSize && wordIndex + i < textArray.length) | |
{ | |
var word:String = textArray[wordIndex + i]; | |
buffer.push(word); | |
i++; | |
} | |
var bufferToBePushed:String = buffer.join(" "); | |
var wordsToBeWritten:String = pageArray[pageIndex] == null ? bufferToBePushed : pageArray[pageIndex] + " " + bufferToBePushed; | |
textContent.htmlText = wordsToBeWritten; | |
if (textContent.textHeight > textContent.height - 20) | |
{ | |
fetchSize = fetchSize / 4; | |
if (buffer.length == 1) | |
{ | |
pageArray[pageIndex] = wordsToBeWritten; | |
wordIndex = wordIndex + i; | |
pageIndex++; | |
return; | |
} | |
else | |
{ | |
generatePaging(fetchSize); | |
} | |
} | |
else | |
{ | |
pageArray[pageIndex] = wordsToBeWritten; | |
wordIndex = wordIndex + i; | |
generatePaging(fetchSize); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment