Regarding using a try/catch for this, in your catch you can check the
errorID, if it's 1006, it's a method not found. You can catch all the
run-time errors listed in the appendixes of the flash help. Not knowing
everything going on in your code, you might want to check it in case
something else throws a error during run-time.


                        catch (m_e:Error)
                        {
                                switch(m_e.errorID)
                                {
                                        case 1006:
                                                // Function/Method not
found
                                                trace(" -- METHOD NOT
FOUND -- ");
                                                break;



Ben 



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ian
Thomas
Sent: Thursday, 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 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
executed when processing completes and exits any try/catch block but
before (potentially) the function returns. It leads to a return path
that you might not expect.

  I completely agree that you should try to avoid using try/catch
instead of an 'if' statement - however the ReferenceError solution I
posted above is several magnitudes faster than generating then parsing
then searching through the XML result from describeType, and I felt it
worth the sacrifice. Sometimes you've got to throw elegance to the
wind and adopt practicality. However, in the end
Object.hasOwnProperty() was the solution, I was being stupid, and the
ReferenceError solution isn't needed; so it's academic. :-)

Ian

On Thu, Oct 30, 2008 at 2:21 AM, Steven Sacks <[EMAIL PROTECTED]>
wrote:
> 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
> returning inside them since I first started using them because of the
bug.
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to