Hi,

> If a variable is of type Boolean in AS (not JS), is there a
> difference between these three patterns.

No as a boolean can only have the values of true and false and defaults to 
false in AS.

If you take the same code and run it in the browser it can now have three 
values, true, false and undefined and it defaults to undefined.

Currently this is cause bugs as undefined != false in JS.

For example this program with incorrectly get "B is true” in the browser and “B 
is false” in the flash player.

<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
               xmlns:js="library://ns.apache.org/flexjs/basic" 
applicationComplete="init()">

   <js:valuesImpl>
       <js:SimpleCSSValuesImpl/>
   </js:valuesImpl>

   <fx:Script><![CDATA[
           protected function init():void
           {
               var b:Boolean;

               if (b == false) {
                   trace("B is false");
               }
               else {
                   trace("B is true");
               }
           }
       ]]></fx:Script>

   <js:initialView>
       <js:View percentWidth="100" percentHeight="100">
       </js:View>
   </js:initialView>

</js:Application>

It is however a simple example and the same issue will also occur in any case 
where you end up comparing a freshly defined boolean (i.e. undefined) with an 
expression that evaluates to false so just converting (b == false) to (!b) 
would not be enough to solve the issue.

Thanks,
Justin

Reply via email to