Weird Flash 8 compiler bug?


I haven’t delved into this in detail (so it could simply be an error on my part), but I had a function that returns a string. The string is long and complex, so my return statement looked something like this:

return
    'string stuff'
    + ' more string stuff ' + someVariable + 'string stuff'
    + ' more string stuff'
    + ' more string stuff'
    /* ... about 20 lines of this ... */
    + ' more string stuff';

The resulting function always returned undefined instead of the string.

Baffled, I changed the code to look like this:

var result:String =
    'string stuff'
    + ' more string stuff ' + someVariable + 'string stuff'
    + ' more string stuff'
    + ' more string stuff'
    /* ... about 20 lines of this ... */
    + ' more string stuff';
return result;

…and that worked as expected. Huh.

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
AIR Monster Attack updated to latest beta
on AIR Bus Tour Photos

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

This is a Javascript misfeature: Javascript automatically inserts missing semicolons in some cases, and it is doing it here because of the newline after return.

Aha, I see! I keep forgetting how JavaScript allows you to leave out semicolons.