As long as you know the property you are GETTING is really a function.
There's a bug in the Flash player/compiler - or at least some see it
as a bug, but Adobe is convinced it's not.

This statement:

this[myFunction]();

will NOT call callProperty. It will instead call getProperty, for
which you MUST return a function or an exception is thrown.

Why is that a bug? Because this statement:

this.myFunction();

calls callProperty, as expected, but the [] notation does not. You
MUST know that when getProperty is being called that you are to return
a function.

If you are dealing with a known and limited set of methods/properties,
then that can be worked around. However, if you're dealing with many
methods/properties, or worse, if you are dealing with a dynamic set of
methods/properties, then you're up the creek.

There's a bug report here:
https://bugs.adobe.com/jira/browse/ASC-2812

Note my arguments for why this is a bug and how it's very visible in
the XML object.


On Fri, May 9, 2008 at 5:46 PM, Corey Smaller <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
> thanks Tracy, that did the trick!
>
>
>
>  --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>  >
>  > If the functions exist, and you have the names in the xml, you can use
>  > bracket notation to resolve the references:
>  >
>  > this[myFunction]();
>  >
>  >
>  >
>  > Tracy
>  >
>  >
>  >
>  > ________________________________
>  >
>  > From: [email protected] [mailto:[EMAIL PROTECTED] On
>  > Behalf Of Corey Smaller
>  > Sent: Friday, May 09, 2008 5:14 PM
>  > To: [email protected]
>  > Subject: [flexcoders] calling different methods through XML and Flash
>  > Proxy class?
>  >
>  >
>  >
>  > ok, im a little confused. I need to be able to call many different
>  > methods based on whatever comes in through the XML (ie- the XML would
>  > have a "function" node that names a preexisting function to handle
>  > whatever data comes in). My idea is to have one class that sends and
>  > receives the XML (DatabaseRequest.as for example) and then calls
>  > whatever function/class to set up the proper swf based on the XML
>  > data. like this
>  >
>  > <function>createVideoSection</function>
>  >
>  > Instead of using a ton of if/then statements is there an easier way to
>  > just call the function (even though the data comes in as XML) or
>  > create a class that interprets it??
>  >
>  > I read a few examples on the Proxy class and maybe i am going in the
>  > right direction? its friday, Im tired, and its raining.
>  >
>  > from what I have read on the Proxy class you need to override
>  > flash_proxy_function CallProperty like so (taken from livedocs):
>  >
>  > //code
>  >
>  > override flash_proxy function callProperty(methodName:*, ... args):* {
>  > var res:*;
>  > switch (methodName.toString()) {
>  > case 'clear':
>  > _item = new Array();
>  > break;
>  > case 'sum':
>  > var sum:Number = 0;
>  > for each (var i:* in _item) {
>  > // ignore non-numeric values
>  > if (!isNaN(i)) {
>  > sum += i;
>  > }
>  > }
>  > res = sum;
>  > break;
>  > default:
>  > res = _item[methodName].apply(_item, args);
>  > break;
>  > }
>  > return res;
>  > }
>  >
>  > //end code
>  >
>
>  



-- 

Derek Vadneau

Reply via email to