Welcome to WebmasterWorld Guest from 54.226.130.194

Forum Moderators: open

Message Too Old, No Replies

if (false) {} causes strange behavior in AS3

it makes the publishing go wrong without notice

     

gergoe

12:56 pm on Jul 31, 2008 (gmt 0)

10+ Year Member



If you ever happen to use the following (at least it was the case with me, using Flash CS3 with ActionScript 3):
if (false) { 
// Old code
} else {
// New (candidate) code
}

...then don't be surprised if the published movie does not work anymore. Modifying the code to:

if (!true) { 
// Old code
} else {
// New (candidate) code
}

...solves the problem. Weird enough.

Looks as if the compiler crashes at this point in the movie, it behaves as if it were a compile error - but without any error message.

rocknbil

4:18 pm on Jul 31, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



A little more info? True and false are reserved words. Are you saying you are creating variables named true and false, and take actions whether or not they exist?

if (some_event) { var myVar = 1; }

if (myVar) {
// this should work
)

gergoe

10:14 pm on Jul 31, 2008 (gmt 0)

10+ Year Member



No, nothing like that. true is the boolean constant true, and false is its counterpart. Just simply pointed out that for me using

if (false) { somecode } else { someothercode }

...stops the movie being compiled properly. Anything other than that works (1==0, !true or true&&false), but if I just use false as the condition, that doesn't.

Nothing needs to be solved here, just found it interesting enough to post it here, might come handy for someone (or a good start for experimenting or bug reporting :-)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month