I thought I'd create a test case to test this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
     applicationComplete="onApplicationComplete()">
     <mx:Script>
         <![CDATA[
             import mx.controls.Alert;

             private function onApplicationComplete():void
             {
                 var x:Boolean = true;
                 var y:Boolean = false;

                 if(x == true && y == false)
                 {
                     doSomething();
                 }
                 else if(x== false && y == false)
                 {
                     if( x == true)
                    {
                           Alert.show("Should never happen.");
                     }
                     doSomethingElse();
                 }
                 else
                 {
                  //do nothing
                 }
             }

             private function doSomething():void {}
             private function doSomethingElse():void {}
         ]]>
     </mx:Script>
</mx:Application>


It works fine. No Alert box.

How are you invoking this code. It has to be something else.


--- In flexcoders@yahoogroups.com, Cordova Aaron <basic...@...> wrote:
>
> I have an if else block that is matching every combination, all at
once.
>
> To verify what I was suspecting I hard coded values to make portions
of the block impossible but they are still occuring, I'm assuming that
the project is not being rebuilt but when I comment lines, the code is
no longer executed, but the block is still executed.
>
> example
>
> x = true;
> y = false;
>
> if(x == true && y == false)
> {
>     doSomething();
> }
> else if(x== false && y == false)
> {
>     if( x == true)
>    {
>           Alert.show("Should never happen.");
>     }
>     doSomethingElse();
> }
> else
> {
>  //do nothing
> }
>
> In my example I'm sure that I should never see the alert message, but
I get it the message every time the code is executed. I ran the 'Clean'
option in under the Build menu and the source recompiled, the problem
remains.
>

Reply via email to