[Laszlo-dev] setters in swf9
henry.minsky at gmail.com
Fri Feb 1 08:23:57 PST 2008
Yes, look at LaszloView.js or LzText.js for examples what I've been
doing. I declare static class vars like this, which make copies of
the superclass's setters vars
static var getters = new LzInheritedHash(LFCNode.getters);
static var defaultattrs = new LzInheritedHash(LFCNode.defaultattrs);
static var options = new LzInheritedHash(LFCNode.options);
static var setters = new LzInheritedHash(LFCNode.setters);
static var __LZdelayedSetters:* = new
static var earlySetters:* = new LzInheritedHash(LFCNode.earlySetters);
And the base constructor in LFCNode (which is the 'static' version of
LzNode, see core/LzNode.js) automatically copies these class vars to
the corresponding instance vars when a node is constructed.
Note, there's an issue at runtime that comes up if you have code which
tries to set arbitrary properties on
a class which have not been declared at compile time. To allow this,
the class has to be declared 'dynamic'.
Eventually we're going to make <attribute> declarations cause
compile-time declarations of instance vars, but we don't do that yet
so I've been doing the following thing:
I have an idiom I am using in LzNode and LzView whereby I have an
"internal" class, LFCNode, or LFCView, which is not declared
'dynamic', and then I have a kind of 'wrapper' class which I declare
as 'dynamic', (e.g., LzNode, LzView). This is to get the (hoped for)
benefit of the as3 compiler making more efficient
code for accessors to methods and instance vars of these
superclasses because they are not declared dynamic.
For the data classes, I think they can all just be left as they are,
and not declare them dynamic, and see if we can get them to compile.
For now if something subclasses LzNode, just leave it doing that.
Eventually we may want to make that subclass LFCNode instead. At
runtime, if we discover that there are classes where code which is
adding properties dynamically at runtime, we can see about making a
'dynamic' subclass for those classes, or
just declare them dynamic, or something.
On Fri, Feb 1, 2008 at 10:27 AM, Philip Romanik
<promanik at laszlosystems.com> wrote:
> Hi Henry,
> What is the "new" way to handle setters in swf9? The solution you're
> using in LaszloView looks like,
> static var setters = new LzInheritedHash(LFCNode.setters);
> LFCView.setters.clip = -1;
> Should I use this same approach with the files I'm porting?
hminsky at laszlosystems.com
More information about the Laszlo-dev