Ah nice... Cheers Oleg. I always put my break; statement inside the case brackets. I quite like the 1st way... Easier to read I think.
Thanks, Nick On 25 March 2010 12:49, Oleg Sivokon <olegsivo...@gmail.com> wrote: > > > In AS3 switch construction uses break - otherwise it'll fall through (all > cases will be executed after the first case that matches the condition). > Besides, you can leave the condition blank and put any statement in the > case block, however, you have to be careful that the cases are unique. > Example: > > switch ( true ) > { > case (orgStructureADG.selectedItem is VendorCompcodeData): > { > trace( "VendorCompcodeData" ); > } > break; > case (orgStructureADG.selectedItem is VendorPurchorgData): > { > trace( "VendorPurchorgData" ); > } > break; > default: > { > trace( "default" ) > } > } > > However, I would do it like this: > > switch ((orgStructureADG.selectedItem as Object).prototype) > { > case VendorCompcodeData: > { > trace( "VendorCompcodeData" ); > } > break; > case VendorPurchorgData: > { > trace( "VendorPurchorgData" ); > } > break; > default: > { > trace( "default" ) > } > } > > Best. > > Oleg > >