Reputation: 205
I have an image bell. I want this to be animated such that it from right-to- left and left-to-right indefinitely. I tried with the following coding but I'm unable to achieve it:
var curWin = Ti.UI.createWindow;
var nButto = Ti.UI.createButton({
backgroundImage : "/images/bell.png",
height : 29,
width : 29,
top : 0,
enabled : false,
textAlign : Titanium.UI.TEXT_ALIGNMENT_RIGHT,
font : {
fontFamily : 'OpenSans-Regular',
fontSize : 17
}
});
curWin.add(nButto);
var matrix = Ti.UI.create2DMatrix();
matrix = matrix.rotate(90);
var a = Ti.UI.createAnimation({
transform : matrix,
duration : 500,
autoreverse : true,
repeat : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT ,
});
var matrix1 = Ti.UI.create2DMatrix();
matrix1 = matrix.rotate(180);
var a1 = Ti.UI.createAnimation({
transform : matrix1,
duration : 500,
autoreverse : true,
repeat : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT ,
});
nButto.animate(a);
nButto.animate(a1);
nButto.anchorPoint = {
x : 0.5,
y : 0.5
};
Upvotes: 0
Views: 67
Reputation: 2041
You can add an eventListener to both animation, call animation 2 in the complete listener of 1 and 1 in the listener of 2.
a.addEventListener('complete',function(e){
//your code for callback function here.
});
Upvotes: 1