Well I thought our handlers were supposed to be compiled with
'implicit this'.
Perhaps Don left this out, because this _is_ implicit in AS3 method
bodies? If so, we should make the tag compiler output anonymous
handlers like this as methods not functions. This would mean we would
have to start emitting those anonymous singleton classes for views
that add methods...
On 2008-01-09, at 23:06 EST, Henry Minsky wrote:
I've got a little test LZX code that has a click handler like this:
<view id="bar" x="200" y="200" >
<view id="foo" bgcolor="0xcccccc" x="-100" y="-100" height="200"
width="200"
onclick="parent.animate('rotation', 360, 1500, true)"
When I compile it I get this error from the flex compiler
/cygdrive/c/flex2/bin/mxmlc -debug=true
-library-path+=../../../lps/includes/lfc/LFC9.lzl -default-size 800
600
-default-frame-rate 60 DemoApp.as
Loading configuration file C:\flex2\frameworks\flex-config.xml
C:\users\hqm\openlaszlo\devildog\WEB-INF\lps\lfc\DemoApp.as(49):
col: 20
Error: Call to a possibly undefined method animate through a
reference with
static type flash.display:DisplayObjectContainer.
parent.animate('rotation', 360, 1500, true)
^
The handler is compiled to a function inside of the usual stuff
passed to a
call to LzInstiateView:
LzInstantiateView({attrs: {id: "bar",
x: 200,
y: 200},
children: [{attrs:
{$delegates: ["onclick", "$m1", null,
"oninit", "$m2_foo_reference", null],
$m1: function foo_$m1() {
parent.animate('rotation', 360, 1500, true)
}, ...
So I am not sure in what context the compiler thinks that "parent"
is being
looked up.
If I change the code to refer to "this.parent", it compiles happily,
and
appears to work
<view id="bar" x="200" y="200" >
<view id="foo" bgcolor="0xcccccc" x="-100" y="-100" height="200"
width="200"
onclick="this.parent.animate('rotation', 360, 1500, true)"
--
Henry Minsky
Software Architect
[EMAIL PROTECTED]