gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-dev] How do I implement a function in a flash package?


From: strk
Subject: Re: [Gnash-dev] How do I implement a function in a flash package?
Date: Tue, 26 Aug 2008 10:07:10 +0200

On Tue, Aug 26, 2008 at 02:28:57PM +0800, Tom Stellard wrote:
> >
> > > I have tried adding the package to the native class array, but  the AVM2
> > > still cannot find the function when I search the global object, using the
> > > as_object::findProperty function.
> >
> > With the AVM1 layout, and what you find in the 'flash' package as existing
> > gnash code, you need to fully qualify the names, thus:
> >
> >        flash.utils.getQualifiedClassName();
> >
> > Any other way to call it must rely on scope chain (which usually ends
> > with the _global object being scanned).
> >
> >
> I think this is what AVM2 is trying to do.  AVM2 takes a property
> 'getQualifiedClassName' and a namespace 'flash.utils' and searches the
> objects in the scope stack for a match.  The Global object is always one of
> the objects in the scope stack.  Is it best for me to add this property
> directly to the gobal object, with a call like
> global.init_member("getQualifiedClassName,new
> builtin_function(getQualifiedClassName),flags,NSV::NS_FLASH_UTILS); or is
> there some way to search the global object and all of its "children" for a
> match, so in this case, the search would go
> Global->flash->utils->getQualifiedClassName?

With AVM1, variables lookup using scope chain is handled by as_environment.
The ::get_variable method checks for variables in 'dot-notation', that is
something like: flash.utils.getQualifiedClassName. If you pass it something
like that it will scan the scope chain till it finds an object that contains
a 'flash' child, then will lookup 'utils' from there and then
'getQualifiedClassName'. Dunno if this is the expected chain of events 
for AVM2 though. If it is it would have no sense to support any concept
of 'namespace'. Never used the 'namespace' parameter of get_member/init_member
so no idea how it would work.

--strk;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]