Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

How can this be wrong? Help!

Surely the code below should move a red square directly downwards by 150 pixels…?!

var win = Ti.UI.currentWindow;

var tester = Ti.UI.createView({
    width:50,
    height:50,
    backgroundColor:'#f00',
    left:0,
    top:0
});
win.add(tester);

var t = Titanium.UI.create2DMatrix();
t.translate(0,150);
tester.animate({transform:t, duration:1000});

Instead it moves down and to the right…!

Can anybody shed any light on what may be going wrong?

— asked June 28th 2010 by Steffan Luczyn
  • animate
  • animation
0 Comments

1 Answer

  • Try to define an animation with Titanium.UI.createAnimation and pass it to the animate function instead of putting it like you are doing it now.

    — answered June 28th 2010 by Dan Tamas
    permalink
    1 Comment
    • Still doesn't work…

      var win = Ti.UI.currentWindow;
      
      var tester = Ti.UI.createView({
          width:50,
          height:50,
          backgroundColor:'#f00',
          left:0,
          top:0
      });
      win.add(tester);
      
      var t = Ti.UI.create2DMatrix();
      t.translate(0,150);
      
      /*var a = Ti.UI.createAnimation({
          transform: t,
          duration:1000
      });*/
      
      var a = Ti.UI.createAnimation();
      a.transform = t;
      a.duration = 1000;
      
      tester.animate(a);
      

      Same thing happens. (The commented out code actually performs no animation whatsoever!)

      — commented June 28th 2010 by Steffan Luczyn
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.