You're getting the warning because LzView.x is documented as a number - not an expression.

The compiler needs to be told if you want the expression to be evaluated once (by using a $once{} expression) or kept up-to-date when values in the expression change. The compiler compiles ${} constraints into a number of functions that kind of watch bound-from fields and update the bound-to fields.


If I'm not mistaken, if the below value was written was rewritten as a ${} expression, functions would be created to watch for changes in video, video.videoframe, video.numframes, immediateparent, immediateparent.width, this.margin, and this.rightmargin. If you don't expect the widths and margins to change, you can rewrite this by watching only the value that is expected to change at runtime -

  <handler name="onvideoframe" reference="video">
    var newx=Math.round((video.videoframe/video.numframes)
        * (immediateparent.width - this.margin - this.rightmargin)
        + this.margin);
     this.setAttribute("x", newx);
  </handler>

This is a step away from the cool declarative syntax of ${} expressions but it will lead to a smaller memory footprint in your compiled app.

I'd alsoexpect the warnings to go away if you rewrote the expression as a constraint in the attribute -

    <class name="myscrubber"
        x=Math.round((video.videoframe/video.numframes)
        * (immediateparent.width - this.margin - this.rightmargin)
        + this.margin)" />

HTH,
-e

---=---===-------
Elliot Winard
Sr. Software Engineer
Webtop Team
---=---===-------


On Sun, Jul 15, 2007 at 12:07 AM, Robin Sheat wrote:

I have this:
<attribute name="x" value="Math.round((video.videoframe/video.numframes) * (immediateparent.width - this.margin - this.rightmargin) + this.margin)" />

In order to get the x value of the component to track a video. However, I get the warning: timeline/frameline.lzx:12:34: Use x="${Math.round((video.videoframe/video.numframes) * (immediateparent.width - this.margin - this.rightmargin) + this.margin)}" instead.

I can't use x=... in the class definition in this file, as it refers to attributes that haven't been declared at that stage and so I get warnings when it starts up. Why is this warning here, and how can I suppress it (or is there a better way to do this?)

--
Robin <[EMAIL PROTECTED]> JabberID: <[EMAIL PROTECTED]>

Hostes alienigeni me abduxerunt. Qui annus est?

PGP Key 0xA99CEB6D = 5957 6D23 8B16 EFAB FEF8 7175 14D3 6485 A99C EB6D

Reply via email to