[Laszlo-user] Question about applyConstraintMethod()

J Crowley jcrowley at laszlosystems.com
Mon Nov 3 15:05:41 PST 2008


So, I'm working on bringing all the charting stuff up to speed so that 
we can finally get that checked in appropriately, and I have a bunch of 
instances of applyConstraint() that need to be changed.  So what I did 
was, I took the functions and made methods out of them, but I'm not sure 
exactly what to feed into applyConstraintMethod() to get it to work the 
same way.  For instance, part of my code block looks like:

          if(this.charttype == "bar"){
              if(this.drawaxis == 'x'){
                  var f = function(ignore=null){                         
this.setAttribute("x", this.barlink.x + (this.barlink.width / 2) -
                          (this.width / 2));                         }
                  var d = [this.barlink, "x"];
                  this.applyConstraint("x", f, d);
                  var ff = function(ignore=null){
                      this.setAttribute("y", this.barlink.y - 
this.height - 4);
                  }
                  var dd = [this.barlink, "y"];
                  this.applyConstraint("y", ff, dd);
                  if(this.fadein == true){
                      this.fader.doStart();
                  }
              }

So what I did was, I made methods for these:

      <method name="constrainBarDrawXX" args="ignore=null">
          this.setAttribute('x', this.barlink.x + (this.barlink.width / 
2) - (this.width / 2));
      </method>
      <method name="constrainBarDrawXY" args="ignore=null">
          this.setAttribute('y', this.barlink.y - this.height - 4);
      </method>

...and changed the script to:

if(this.charttype == "bar"){
              if(this.drawaxis == 'x'){
                  this.applyConstraintMethod("constrainBarDrawXX", 
[this.barlink, x, this, x]);
                  this.applyConstraintMethod("constrainBarDrawXY", 
[this.barlink, y, this, y]);
                  if(this.fadein == true){
                      this.fader.doStart();
                  }

However, the labels now don't exhibit the same behavior as when they 
were using applyConstraint().  What am I doing wrong?

Thanks!
Josh



More information about the Laszlo-user mailing list