RE: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-30 Thread Schmidtke, Ben
, October 30, 2008 3:28 AM To: Flash Coders List Subject: Re: [Flashcoders] AS3 - Checking if a Function Exists Hi Steven, Thanks for the explanation. If you mean Moock's Essential Actionscript, I've had a read of that section and AFAICS it doesn't mention a bug. The only r

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-30 Thread Ian Thomas
Hi Steven, Thanks for the explanation. If you mean Moock's Essential Actionscript, I've had a read of that section and AFAICS it doesn't mention a bug. The only real issue I know of in try/catch do with return is that you shouldn't put a return in a finally clause, because finally gets e

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-29 Thread Steven Sacks
There's a bug if you return in a try or catch (maybe it's just catch). Colin Moock mentions it in his AS3 book. I personally think it's cleaner to return after a try catch because try catch is not an if else and really shouldn't be treated as such, but that might be because I have avoided retu

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-29 Thread Ian Thomas
Thanks for the tip, Steven - any info as to why? If the error is thrown, the function returns; if it isn't thrown, the function returns. Is this just 'good practice' - if so, instead of blindly following dogma, I'd like a little insight as to _why_ it's good practice? (I've had issues like this in

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-28 Thread Paul Andrews
- Original Message - From: "Steven Sacks" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Wednesday, October 29, 2008 2:20 AM Subject: Re: [Flashcoders] AS3 - Checking if a Function Exists Do not call return in a try catch. Are you suggesting that as ba

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-28 Thread Steven Sacks
Do not call return in a try catch. Ian Thomas wrote: Method: public static function refExists(obj:Object,name:String):Boolean { try { if (obj[name]!=null) return true; } catch (e:ReferenceError) {} return false; }

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-28 Thread Ian Thomas
: Flash Coders List > Subject: Re: [Flashcoders] AS3 - Checking if a Function Exists > > Method: > >public static function refExists(obj:Object,name:String):Boolean >{ >try >{ >if (obj[name]!=null) >return true; >

RE: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-28 Thread Karim Beyrouti
This is great - thank you -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: 28 October 2008 08:46 To: Flash Coders List Subject: Re: [Flashcoders] AS3 - Checking if a Function Exists Method: public static function refExists

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-28 Thread Ian Thomas
Method: public static function refExists(obj:Object,name:String):Boolean { try { if (obj[name]!=null) return true; } catch (e:ReferenceError) {} return false; } HTH, Ian On Tue, Oct 28, 2008 at 8:36 AM, Ian Thomas

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-28 Thread Ian Thomas
Or, thinking about it, you could catch the reference error in a try/catch block. It's more of a kludge, but might give you much higher performance! Ian On Tue, Oct 28, 2008 at 8:33 AM, Ian Thomas <[EMAIL PROTECTED]> wrote: > I'm afraid I don't think either Han's or Steven's solutions work in > AS

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-28 Thread Ian Thomas
I'm afraid I don't think either Han's or Steven's solutions work in AS3 - you'd still get a ReferenceError (unless currentSection is dynamic). I'd do it using flash.utils.describeType, like so: import flash.utils.describeType; : var desc:XML=flash.utils.describeType(currentSection); if (desct.

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-27 Thread Steven Sacks
if (currentSection.refresh) { currentSection.refresh(); } Karim Beyrouti wrote: Hello Group - This should be really easy. I am trying to find out how to check if a function exists or not in AS3 - I tried this: If ( currentSection.refresh != null ) { currentSect

Re: [Flashcoders] AS3 - Checking if a Function Exists

2008-10-27 Thread Hans Wichman
If ( currentSection["refresh"] != null ) { currentSection["refresh"](); } ? grtz JC > > On Mon, Oct 27, 2008 at 3:02 PM, Karim Beyrouti <[EMAIL PROTECTED]> wrote: >> Hello Group - >> >> This should be really easy. I am trying to find out how to check if a >> fu

[Flashcoders] AS3 - Checking if a Function Exists

2008-10-27 Thread Karim Beyrouti
Hello Group - This should be really easy. I am trying to find out how to check if a function exists or not in AS3 - I tried this: If ( currentSection.refresh != null ) { currentSection.refresh(); } But I get "ReferenceError: Error #1069: Property refresh no