cannot reference global var from function definition in swf9

View: New views
2 Messages — Rating Filter:   Alert me  

cannot reference global var from function definition in swf9

by Henry Minsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm getting this error
[/tmp/lzswf9/lzgen46172/$lzc$class_xmlrpc.as: 18] line unknown: Error:
Access of undefined property LzXMLRPCService.

from  code which refers to the global var LzXMLRPCService


                if ( this.proxy[method] == null ) {
                    this.proxy[method] = function (paramArr, delegate) {
                        var args = arguments.callee.args;
                        LzXMLRPCService.invoke(delegate, paramArr,
                            { service: args.service, methodname: args.method},
                              args.secure, args.secureport);
                    }
                    this.proxy[method].args = {
                        service: this.service,
                        method: method,
                        secure: this.secure,
                        secureport: this.secureport
                    }
                }

The var is declared at the top level as

var LzXMLRPCService:LzXMLRPC = new LzXMLRPC();

and it exists and regular references to it compile in the code, but
for some reason, inside of the function ()  expression, it
says it is undefined.

I can't figure out if I'm doing something wrong, or if this is a
compiler bug (in the flex compiler?)

Maybe I ought to rewrite this code to operate in a different manner, I
think it is a little
dicey to try to be adding properties to a function object in swf9
anyway, I recall that
failed when trying to add properties to a method.

--
Henry Minsky
Software Architect
hminsky@...

Re: cannot reference global var from function definition in swf9

by P T Withington :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We determined that this was due to the closure being created in a  
method which had a `with(this)` automatically inserted.

Really a bug in the flex compiler, but my change of yesterday which  
removes the superfluous `with(this)` from swf9 methods makes the  
problem go away.

Henry will report to Adobe.

On 2008-07-23, at 10:46EDT, Henry Minsky wrote:

> I'm getting this error
> [/tmp/lzswf9/lzgen46172/$lzc$class_xmlrpc.as: 18] line unknown: Error:
> Access of undefined property LzXMLRPCService.
>
> from  code which refers to the global var LzXMLRPCService
>
>
>                if ( this.proxy[method] == null ) {
>                    this.proxy[method] = function (paramArr,  
> delegate) {
>                        var args = arguments.callee.args;
>                        LzXMLRPCService.invoke(delegate, paramArr,
>                            { service: args.service, methodname:  
> args.method},
>                              args.secure, args.secureport);
>                    }
>                    this.proxy[method].args = {
>                        service: this.service,
>                        method: method,
>                        secure: this.secure,
>                        secureport: this.secureport
>                    }
>                }
>
> The var is declared at the top level as
>
> var LzXMLRPCService:LzXMLRPC = new LzXMLRPC();
>
> and it exists and regular references to it compile in the code, but
> for some reason, inside of the function ()  expression, it
> says it is undefined.
>
> I can't figure out if I'm doing something wrong, or if this is a
> compiler bug (in the flex compiler?)
>
> Maybe I ought to rewrite this code to operate in a different manner, I
> think it is a little
> dicey to try to be adding properties to a function object in swf9
> anyway, I recall that
> failed when trying to add properties to a method.
>
> --
> Henry Minsky
> Software Architect
> hminsky@...