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/