Stack Error 1023 - My Strange Encounter With Error 1023

The mysterious Error #1023: Stack overflow occurred can spring in the most unlikely places.

 

For one project that I was working on the error never occurred in the test environment, but showed up as soon as we pushed to the production environment, which made it extra tricky to troubleshoot.
After hours of searching the net and trying different things we discovered the cause of the problem.  Notice the difference between these two code samples.....

//SAMPLE 1 - caused the stack overflow error:
for each(dObj in arChildren){
    if(dObj is MyTextArea){
        var ta:MyTextArea = maxTextArea(dObj);
        ta.htmlText = ta.originalContent;
    }
}



//SAMPLE 2 - no error:
var ta:MyTextArea;
for each(dObj in arChildren){
    if(dObj is MyTextArea){
        ta = MyTextArea(dObj);
        ta.htmlText = ta.originalContent;
    }
}

 

This encounter was a good lesson for me to tighten up my coding practices and avoid object creation when it's not necessary.


RECENT ARTICLES