Silent error using Return statment in ActionScript
- August 11th, 2007
- Write comment
A friend of mine was having problem with some ActionScript code on a frame and couldn’t figure out why part of it was working and then it just stopped working. I took a quick look at this code and immediately saw a “return” statement where it shoudn’t be. It was outside of a function and probably something that got copied-n-pasted from somewhere else.
So here is a puzzler, Flash didn’t throw an error about this return being outside of a function and I have no idea where the flow of the code would return to. I did a quick test of it in a AS3 file and got the same behavior.
Is this something Flash should be throwing an error on? If not, why?
Here is a quick code snippet:
[as]trace (“fe fi fo”);
return;
trace(“fum”);
// traces fe fi fo, but no fum
[/as]