[flexcoders] double check that this Switch statement can't work...

2010-03-25 Thread Nick Middleweek
Hi, I was hoping I could use a switch statement to test what Object type is selected on my ADG but I don't think it's possible and need to use an if, else if, chain... if ( orgStructureADG.selectedIndex = 0 ) { switch ( orgStructureADG.selectedItem ) { case VendorCompcodeData:

Re: [flexcoders] double check that this Switch statement can't work...

2010-03-25 Thread Oleg Sivokon
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:

Re: [flexcoders] double check that this Switch statement can't work...

2010-03-25 Thread Oleg Sivokon
Sorry, typo... switch ((orgStructureADG.selectedItem as Object).constructor) { case VendorCompcodeData: { trace( VendorCompcodeData ); } break; case VendorPurchorgData: { trace( VendorPurchorgData ); } break;

Re: [flexcoders] double check that this Switch statement can't work...

2010-03-25 Thread Nick Middleweek
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