You shouldn't have to cast as an object. And, according to the docs, you
should be able to simply add a property to a function and access it. No
offense - I really do appreciate the effort to help me out - but casting
seems to be a bit of a hack. Although I like AS3 there are some things that
were so simple in AS1/AS2 that are just not possible, or require workarounds
that really seem like hacks.

All I wanted to do was give some context to a function so when it is called
it could grab that context info. An example of what people have wanted from
this from the MX days is getting the name of the function for various
reasons, including debugging and logging. My particular reason is a little
more complex and probably seems strange unless you know the entire context
of what I'm trying to do, but here goes ...

I built a class that extends Proxy. The idea is that someone would call a
function on the instance of the class and I would resolve it from a
dynamically added manifest. That part isn't hard, using the override for
callProperty. However, if someone tries to call a function using [] syntax
the getProperty override is actually called, and a function is expected to
be returned. Unfortunately, that scenario breaks what I was trying to
accomplish since it means I need to return an actual function object and the
function is not able to know it's name for me to determine if the call
should go through or return an error. I could determine this in the
getProperty override, but I don't necessarily know if the user meant to call
a function or access a property.

What I wanted to do was pass a function object back with a property on the
function that was the name of the function. Instead I've had to build a
class that stores a value in a variable and has a method on it that gets
returned from the getProperty override. That is such a waste considering
Function is supposed to be able to do what I want.

So, I have a workaround, but I really want to know whether the documentation
is correct and I've simply missed something, or Adobe needs to clean up the
docs. I've already posted a comment in the LiveDocs asking about this and it
has not yet been approved. That was about a week ago.

Can anyone else confirm this? Or does anyone know how to get the example
code working?


On 12/8/06, Clint Modien <[EMAIL PROTECTED]> wrote:

  Function inherits from Object so you should be able to do...

Object(this.test).prop = "someprop";

Why are you doing this?  What are you trying to do... it sounds
interesting.


Reply via email to