<html>
<body>
Hi Henry,<br><br>
There is code in the data classes that specify setters. For example, this
code is in LzDataText.lzs:<br><br>
setters.data = &quot;setData&quot;;<br><br>
<br>
Can this be done in a static initializer? The original traits use this
method to install setters. The code compiles in swf9 but I don't know if
it works. For example, in the class LzMiniNode_DataNode_DOM (my manually
instantiated class):<br><br>
&nbsp;&nbsp;&nbsp; static function initialize (prototype) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // There will be no setters property in
the trait prototype,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // (and you don't want one there! as it
would shadow the one<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // from LzNode) but it will be there after
LzNode.initialize<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // runs<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (prototype.hasOwnProperty('setters'))
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // since you can't assign
directly to these slots...<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // until LzNode.initialize has
run<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prototype.setters.attributes =
&quot;setAttrs&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prototype.setters.childNodes =
&quot;setChildNodes&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prototype.setters.nodeName =
&quot;setNodeName&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Shouldn't be directly
settable<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
prototype.setters.ownerDocument = &quot;setOwnerDocument&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br><br>
<br><br>
<blockquote type=cite class=cite cite="">Yes, look at LaszloView.js or
LzText.js for examples what I've been doing. I declare static class vars
like&nbsp; this, which make copies of the superclass's setters vars<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; static var getters = new
LzInheritedHash(LFCNode.getters);<br>
&nbsp;&nbsp;&nbsp; static var defaultattrs = new
LzInheritedHash(LFCNode.defaultattrs);<br>
&nbsp;&nbsp;&nbsp; static var options = new
LzInheritedHash(LFCNode.options);<br>
&nbsp;&nbsp;&nbsp; static var setters = new
LzInheritedHash(LFCNode.setters);<br>
&nbsp;&nbsp;&nbsp; static var __LZdelayedSetters:* = new
LzInheritedHash(LFCNode.__LZdelayedSetters);<br>
&nbsp;&nbsp;&nbsp; static var earlySetters:* = new
LzInheritedHash(LFCNode.earlySetters);<br>
&nbsp;<br>
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.<br>
&nbsp;<br>
&nbsp;<br>
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'.<br>
Eventually we're going to make &lt;attribute&gt; declarations cause
compile-time declarations of instance vars, but we don't do that yet so
I've been doing the following thing:<br>
&nbsp;<br>
I have an idiom I am using in LzNode and LzView whereby I have an
&quot;internal&quot; 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&nbsp; accessors to
methods and instance vars of&nbsp; these superclasses because they are
not declared dynamic.<br>
&nbsp;<br>
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.<br>
For now if something subclasses LzNode, just leave it doing that.<br>
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.<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
On Fri, Feb 1, 2008 at 10:27 AM, Philip Romanik
&lt;<a href="mailto:promanik@laszlosystems.com">
promanik@laszlosystems.com</a>&gt; wrote:<br>
&gt; Hi Henry,<br>
&gt; <br>
&gt;&nbsp; What is the &quot;new&quot; way to handle setters in swf9? The
solution you're&nbsp; <br>
&gt; using in LaszloView looks like,<br>
&gt; <br>
&gt;&nbsp; static var setters = new
LzInheritedHash(LFCNode.setters);&nbsp; ...<br>
&gt;&nbsp; LFCView.setters.clip = -1;<br>
&gt; <br>
&gt; <br>
&gt;&nbsp; Should I use this same approach with the files I'm
porting?<br>
&gt; <br>
&gt;&nbsp; Thanks!<br>
&gt; <br>
&gt;&nbsp; Phil<br>
&gt; <br>
&gt; <br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
-- <br>
Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com">hminsky@laszlosystems.com</a>
</blockquote></body>
</html>