I ran into problems like this alot with flash 8 and only once since in Flex 2.   The Flex 2 one involved puting a return statement in one of a few specific lines in one function.  One time I remember I found that might code wasn't exactly perfect (I don't remember how, it was something like using number like it was an integer, but the point is is should have worked anyway), but ever other time I've been stumped and simply kept the trace where it was.  I then remove it at some point later when I forgot it was important and it doesn't give me the error anymore.  So for now do what works and come back to it later and it might be fixed.  I've seen worse hacks than an extra trace statement lying around.

- Dan

On 8/28/06, Ali Mills <[EMAIL PROTECTED]> wrote:
Hi there,

I'm running into what seems to be a bug when nesting an 'if' statement
within a 'switch'.  Here's some code that demonstrates the bug:

<CODE>
package {
        import flash.display.Sprite ;

        public class SwitchBug extends Sprite {
                public function SwitchBug() {
                        var num:Number = 1;
                        var firstNumber:Number = num;
                        var secondNumber:Number = num;
                        tryNumSwitch("go", firstNumber, secondNumber);

                        var now:Date = new Date();
                        var firstDate:Date = now;
                        var secondDate:Date = now;
                        tryDateSwitch("go", firstDate, secondDate);

                        // this method causes a crash
                        tryCrashingDateSwitch("go", firstDate, secondDate);
                }

                private function tryNumSwitch(val:String, firstNumber:Number,
secondNumber:Number):void {
                        switch(val) {
                                case "go":
                                        if(firstNumber == secondNumber) {
                                                trace(">> tryNumSwitch successful !!");
                                        }
                        }
                }

                private function tryDateSwitch(val:String, firstDate:Date,
secondDate:Date):void {
                        switch(val) {
                                case "go":
                                        if(firstDate == secondDate) {
                                                trace(">> tryDateSwitch successful !!");
                                        }
                        }
                }

                private function tryCrashingDateSwitch(val:String, firstDate:Date,
secondDate:Date):void {
                        switch(val) {
                                case "go":
                                        // the compiler crashes on DATE.milliseconds call
                                        if(firstDate.milliseconds == secondDate.milliseconds) {
                                                trace(">> tryCrashingDateSwitch successful !!");
                                        }
                                        // uncommenting the trace below fixes the situation
//                                      trace("Fixed");
                        }
                }
        }
}
</CODE>

Notice, that adding a trace (or any line of code) after the 'if' block
in the third method 'tryCrashingDateSwitch' keeps the player from
crashing.  Has anyone else run into bug?  Does anyone know a good
reason why the crahser would be occuring?

Thanks.


Ali


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/




__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to