[Laszlo-dev] Continued: swf9 and attribute constraint peculiarity
P T Withington
ptw at pobox.com
Mon Oct 5 08:08:46 PDT 2009
This is related to:
http://jira.openlaszlo.org/jira/browse/LPP-7958
So, it appears will still need to improve the error reporting when you
attempt to write a constraint on an object that does not participate
in the OL event system.
http://jira.openlaszlo.org/jira/browse/LPP-7344
But, maybe with the improved runtime error reporting (just added to
trunk), these errors will be more obvious, instead of silently failing?
On 2009-10-05, at 09:50, Rami Ojares / AMG Oy wrote:
> For completeness sake here is the correct formulation of the idea I
> was trying to achieve (I quess I should have posted this on the user
> side)
>
> <canvas debug="true">
> <view name="test">
> <attribute name="someArr" value="new Array()"/>
> <view width="100" height="100" bgcolor="$
> {this.hasElements(parent.someArr) ? 'red' : 'blue'}" x="30" y="45">
> <method name="hasElements" args="attr">
> return attr.length != 0;
> </method>
> <handler name="onclick">
> parent.someArr.push("foo")
> parent.setAttribute("someArr", parent.someArr);
> </handler>
> </view>
> </view>
> </canvas>
>
> Lesson learned:
> Use methods for more complex calculations in constraints and name
> the attributes (dependencies) as arguments.
>
> - rami
>
> Max Carlson wrote:
>> That's correct. Constraints will only work properly with OL
>> attributes. Things like array.length don't tell the runtime when
>> they change, so the constraint doesn't know when to update...
>>
>> Rami Ojares / AMG Oy wrote:
>>> It probably has something to do with the dependencies...
>>> Maybe my code is incorrect when it refers to
>>> "parent.someArr.length" in the constraint?
>>> Am I allowed only to refer to attribute names of laszlo nodes in
>>> constraints?
>>> So that dependencies can be constructed properly.
>>>
>>> - rami
>>>
>>> Rami Ojares / AMG Oy wrote:
>>>> Hi,
>>>>
>>>> I stumbled upon a problem with swf9 (and up) attribute constraints.
>>>>
>>>> Here is sample code that works in swf8 but fails silently in swf9
>>>>
>>>> <!-- The problem is with setting of bgcolor attribute -->
>>>> <canvas debug="true">
>>>> <view name="test">
>>>> <attribute name="someArr" value=" new Array()"/>
>>>> <view width="100" height="100" bgcolor="$
>>>> {parent.someArr.length == 0 ? 'red' : 'blue'}" x="30" y="45">
>>>> <handler name="oninit">
>>>> Debug.inspect(parent.someArr.length == 0)
>>>> </handler>
>>>> </view>
>>>> </view>
>>>> </canvas>
>>>>
>>>> Here the same thing slightly modified so that it works in swf9
>>>>
>>>> <!-- The problem is with setting of bgcolor attribute -->
>>>> <canvas debug="true">
>>>> <view name="test">
>>>> <attribute name="someArr" value=" new Array()"/>
>>>> <view width="100" height="100" bgcolor="$
>>>> {this.hasErrors() ? 'red' : 'blue'}" x="30" y="45">
>>>> <handler name="oninit">
>>>> Debug.inspect(parent.someArr.length == 0)
>>>> </handler>
>>>> <method name="hasErrors">
>>>> return parent.someArr.length == 0;
>>>> </method>
>>>> </view>
>>>> </view>
>>>> </canvas>
>>>>
>>>> So it seems to me that something gets screwed parsing attribute
>>>> constraints in swf9.
>>>> Any ideas?
>>>>
>>>> - rami
>>>
>>
>
More information about the Laszlo-dev
mailing list