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

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

2008-10-30 Thread Schmidtke, Ben
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 real issue I know of in try/catch do

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

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

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 AS3 -

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

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
28, 2008 at 2:13 PM, Karim Beyrouti [EMAIL PROTECTED] wrote: 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

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 Paul Andrews
- Original Message - From: Steven Sacks [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com 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

[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: code If ( currentSection.refresh != null ) { currentSection.refresh(); } /code But I get ReferenceError: Error #1069: Property

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 function exists

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: code If ( currentSection.refresh != null ) {