var mo:MyOther = new MyOther();
var mp:MyProxy = new MyProxy();
mo.nextfunction = mp['go']

this is a very good point.



On 9/27/07, actionscript_czar <[EMAIL PROTECTED]> wrote:
>
>   This doesn't seem to be a bug to me, just looking at it from a
> limited perspective.
>
> Image a class that lookes like this:
>
> class MyClass
> {
> public var go:Function;
>
> public function MyClass( goFunc:Function )
> {
> this.go = goFunc;
> }
> }
>
> In this case go is a property that happens to be a function object.
> So what if using your proxy with another class you did something like
> this:
>
> var mo:MyOther = new MyOther();
> var mp:MyProxy = new MyProxy();
> mo.nextfunction = mp['go']; // could also be mp.go
>
> In that case it would use getProperty and your description is no
> different. When you use the [] operators it gets the property then
> you use the () operators to call the property. The () property is
> expecting a function object on the left hand side. The reason it
> doesn't use callProperty is because the () operators only see a
> function object but don't see it as part of the MyProxy object.
>
> This doesn't mean it couldn't work as you expect in the future, but
> my understanding says the two methods of getting to go are processed
> distinctly for a reason.
>
> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, "Derek
> Vadneau" <[EMAIL PROTECTED]>
>
> wrote:
> >
> > There seems to be a bug in flash.utils.Proxy. Here's some sample
> code:
> >
> > var mp:MyProxy = new MyProxy();
> >
> > mp.myVar = 'something'; // calls flash_proxy setProperty as expected
> >
> > mp['myVar'] = 'something'; // calls flash_proxy setProperty as
> expected
> >
> > mp.go(); // calls flash_proxy callProperty as expected
> >
> > mp['go'](); // calls flash_proxy getProperty - NOT expected
> >
> > Why is getProperty called where the [] operator is used instead of
> the
> > . operator in the case where a function is being called, but not
> when
> > setting a property?
> >
> > And in that case you MUST return a function or a runtime error will
> be thrown.
> >
> > This is unexpected behaviour, as far as I can see.
> >
> > Another example:
> >
> > mp.obj.go();
> >
> > mp['obj']['go'](); // getProperty is called twice, callProperty is
> NOT
> > called at all
> >
> > The issue is that I am dealing with a dynamic API, so I don't always
> > know that 'obj' or 'go' is a property vs. a method.
> >
> > But, because the getProperty is called when a callProperty should be
> > called I am passing an instance of my Proxy class and a runtime
> error
> > is thrown.
> >
> > --
> >
> > Derek Vadneau
> >
>
>  
>



-- 
j:pn
\\no comment

Reply via email to