I've loved using this site for little tips on code, and I try to solve all the errors I can by myself. However, this one has had me stumped for days. I just can't crack it.
RangeError: Error #2006: The supplied index is out of bounds. at flash.text::TextField/setTextFormat() at BibleProgram_fla::MainTimeline/checkAgainstBible() at BibleProgram_fla::MainTimeline/compileInputString() at BibleProgram_fla::MainTimeline/spaceBuild()
function spaceBuild(event:Event):void //This program runs every frame
{
compileInputString();
}
function compileInputString():void
{
inputVerse = inputText.text; // takes text from the input field
inputVerse = inputVerse.toLowerCase();
inputVerse = inputVerse.replace(rexWhiteSpace, ""); //Removes spaces and line breaks
inputVerse = inputVerse.replace(rexPunc, ""); // Removes punctuation
inputVerse = addSpaces(inputVerse); //adds spaces back in to match the BibleVerse
inputVerse = addCaps(inputVerse); //adds capitalization to match the BibleVerse
checkAgainstBible();
}
function checkAgainstBible()
{
outputText.text = inputVerse; // sets output text to be formatted to show which letters are wrong
for(var n:Number = 0; n < inputText.length; n++)
{
var specLetter:String = inputVerse.charAt(n);
if(specLetter != bibleVerse.charAt(n))
{
outputText.setTextFormat(red, n); // sets all of the wrong letters to red
}
}
}
Whenever I run the program and type a string longer than the BibleVerse, it returns the error, but I cannot figure out how to fix it.
I hope I provided enough information for you to help me. If you need more code or something, please ask! Thanks in advance!!