Error #1023: Stack overflow occurred
at MyClass/get id()
Description:
This will happen if the stack has so much data that it is full. Nothing like Thanksgiving dinner to overflow my stack.Β What is a stack and how does it get full you ask. Simply put each method(function) has a stack and that stack stores data associated with the method such as local variables with the method. Although it is a good idea to understand what a stack is you really you don’t need to have an in depth understanding of stacks to understand this error and it’s solution. Basically this error is saying that you are most likely calling the function recursively. Or in other words you might be calling the function from within itself.
Solution:
To rid yourself of ActionScipt error 1023 make sure that you don’t call the method from within itself which will eliminate any type of recursion in your method call. You may be tempted to do this by setting a variable name the same as the function name. Change either one and this will go away. Notice in the ‘Bad Code1’ example that each time the getter returns what you think is an ‘int’ you actually are calling the setter function again recursively. The trace statement will also produce AS3 Error #1023
Bad Code1:
public function set id (myId:int):void
{
this._id = id;
}
public function get id ():int
{
trace(“this.id”,this.id);
return this.id;
}
Good Code1:
public function get id ():int
{
trace(“this.myId”,this.myId);
return this.myId;
}
Bad Code2:
private function recursiveLoop ():void
{
recursiveLoop ();
}
Good Code2:
private function noRecursion():void
{
someOtheFunction ();
}
Adobe actually has a reasonable explanation for this error in liveDocs. Here is a link to the Adobe page that explains ActionScript Error 1023
As always Happy Flashing
I came across this post while I was using recursive function intentionally on Arrays containing Arrays.
But error occurred randomly, sometimes did and sometimes didn’t, on the same data flow.
I found out that the reason for this random occurrence was some Arrays were empty. Therefore, before using function recursively, I checked if Arrays length is more than zero, and problem disappeared.
In reply to Daniele Giardini:
So, 10 years later, but it might still be very useful to someone π
When I tried your code in Flash IDE, I got this trace:
typecheck Untitled_3_fla::MainTimeline/someFunc()
outer-scope = [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ Untitled_3_fla::MainTimeline$]
[Untitled_3_fla::MainTimeline~[O] String[S] String[S] Number[D] *[A]] {} ()
0:getlocal0
[Untitled_3_fla::MainTimeline~[O] String[S] String[S] Number[D] *[A]] {} (Untitled_3_fla::MainTimeline~[O])
1:pushscope
[Untitled_3_fla::MainTimeline~[O] String[S] String[S] Number[D] *[A]] {Untitled_3_fla::MainTimeline~[O]} ()
2:pushstring “result”
[Untitled_3_fla::MainTimeline~[O] String[S] String[S] Number[D] *[A]] {Untitled_3_fla::MainTimeline~[O]} (String~[S])
4:dup
VerifyError: Error #1023: Stack overflow occurred.
The problem is in instantiating variable before you return it, and there’s no other code between instantiation and return.
The solution is to return value without instantiating variable:
function someFunc(x1:String, x2:String, x3:Number=0):String
{
return “result”;
}
someFunc(“someVal1”, “someVal2”);
Also, in reply to John Yaple, solution is:
public function circleVsConcaveVertex(circX:Number, circY:Number, circRad:Number, vertex:AVectorModelData, pEdge:AVectorModelData, nEdge:AVectorModelData):TupleNum
{
return new TupleNum();
}
I had this error happen when I tried to make a function that consisted of the following code.
public function circleVsConcaveVertex(circX:Number, circY:Number, circRad:Number, vertex:AVectorModelData, pEdge:AVectorModelData, nEdge:AVectorModelData):TupleNum
{
var tuple:TupleNum = new TupleNum();
return tuple;
}
It is very odd, as if I modify the function to do something such as perform a trace operation or any form of other function body the function will run just fine.
Please help me out
I am fresher to Flex. i wrote this application for make a brid image fly but i am not able to solve this error as i don’t have anyone with me.. so pleas help me out….
Thanks in Advance….
Deepak
deepak.dynamite@gmail.com
You saved my day π Thanks a lot for sharing.
i have done a blackjack game its written in as3.I’m getting Error: Error #1023: Stack overflow occurred.
after i play so many time.this the function were i think its doing the issue.
function calculateScore(player:Array, score:uint):uint
{
for(var i:uint = 0; i < player.length; i++)
{
if(player[i].cardName == “Ace” && getTotalScore(player) 21)
{
player[i].cardValue = 1;
}
}
score = getTotalScore(player);
if(player == dealerCards && score <= 16)
{
makeCard(dealerCards, dealerContainer);
calculateScore(dealerCards, dealerScore);
}
return score;
}
thank you
Leonardo,
Glad I could help resolve AS3 Error 1023 for you.
Thanks,
Curtis J. Morley
Thanks Curtis, your post helped me today.
I do not have a recursive function, but I am getting this error.
Copy and Paste is not working for me. I get the error in FB3 when I do a “Export Release Version”, but not when I simply do a “Build Project”.
Here is the code for the function that is giving me this error:
// Handle results of Widget Columns WebService
private function sWidgetColumnsResult(_wsResultEvent:wsResultEvent):void
{
// Store the WebService results as an Array Collection
var result:ArrayCollection = _wsResultEvent.result as ArrayCollection;
// Loop through the WebService results Array Collection
for each (var object:Object in result)
{
// Store the Object as a Widget Column Class Instance
var widgetColumn:WidgetColumn = new WidgetColumn(object);
// Set the Widget Column’s Default Display Code to the index of the loop
widgetColumn.PARAMVALUEDISPLAYCODE = widgetColumn.DISPLAYCODE;
// Add the Widget Column Object to the Array Collection of all Widget Columns
widgetColumns.addItem(widgetColumn);
}
}
I’ve tried changing the code to do the loop different ways, but I still get th same error. Any ideas?
Thanks.
Hey Curtis,
I just tried that copy out and back into flash trick, and it worked like a CHARM!
thanks a bunch, I was beginning to doubt my sanity.
Thomas
Oh wow (stayed outta town for a job, thus i’m reading what you last wrote just now). I’m afraid that won’t solve that particular bug, cause my original code was in an external class written with FlashDevelop. But anyway, it’s really a great suggestion: i never thought about that. Thanks, every time i’ll have issues inside Flash i’ll remember you π
Thanks for answering & nice days π
Daniele
Daniele,
I find that every time I run into a wall I copy the ActionScript into a text editor and then paste the exact same ActionScript back into Flash/Flex. This has solved the problem for me about 8 times now. I have had other friends say the same thing. If they copy and paste the ActionScript without changing anything it will often resolve the problem.
Thanks for reading and Happy Flashing
Curtis J Morley
P.S. it suffices to add something between “my_result” declaration and the function return, not to get this error, like:
var my_result:String = βresultβ;
var someVar:String = “”;
return my_result;
And this makes this bug even more queer π
Hi Curtis,
I’m thankful for the help, but I tried it with no other code to be sure it was a bug, and that AS I wrote you is the stripped out version I finally reached.
Just copy&paste the ActionScript I wrote in a new AS3 FLA (without anything else) and you should get the error… Straaaaaaaaange.
Thanks & regards π
Daniele
Daniele,
Is there anything else in your code labeled ‘x3’. A method perhaps? If so, this may be why you are getting this error. If not, I would love to see your file help you find out why you are getting AS3 Error 1023 it could be.
Thanks,
Curtis J. Morley
Hi Curtis,
I found your site while searching around for help with error 1023. While coding it happened to me the strangest thing, and i’m quite sure this is a naughty but…
Try to open a new AS3 FLA file, and write in the Actions Panel this simple code:
function someFunc(x1:String, x2:String, x3:Number=0):String
{
var my_result:String = “result”;
return my_result;
}
someFunc(“someVal1”, “someVal2”);
Calling someFunc will call a stack overflow error!!! The only way not to have it is to remove the “x3” Parameter. That’s sooooooo strange (and annoying, ’cause before realizing this was a bug i was getting crazy trying to find an error in my original code, which was much more complex).
P.S. i’m using FlashPlayer debugging version 9.0.r47, i hope it’s his fault
Kind regards & a nice day,
Daniele