Created
October 8, 2011 19:51
-
-
Save aaronksaunders/1272779 to your computer and use it in GitHub Desktop.
spinning circle in Appcelerator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// | |
var win1 = Titanium.UI.createWindow({ | |
title : 'Tab 1', | |
backgroundColor : '#fff', | |
layout : "vertical" | |
}); | |
// | |
var view5 = Titanium.UI.createView({ | |
backgroundColor : '#336699', | |
top : 60, | |
height : 200, | |
width : 200, | |
anchorPoint : { | |
x : 0.5, | |
y : 0.5 | |
} | |
}); | |
win1.add(view5); | |
var spin = Titanium.UI.createButton({ | |
title : 'spin', | |
height : 40, | |
width : 200, | |
left : (320 - 200) / 2, | |
top : 100 | |
}); | |
var rotate = function(degrees) { | |
var t = Ti.UI.create2DMatrix(); | |
t = t.rotate(degrees); | |
var a = Titanium.UI.createAnimation(); | |
a.transform = t; | |
a.duration = 5; | |
view5.animate(a); | |
setTimeout(function() { | |
rotate(++degrees); | |
}, 5); | |
}; | |
spin.addEventListener('click', function() { | |
rotate(0); | |
}); | |
win1.add(spin); | |
win1.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Aaron. Thanks for this code. It works perfectly. However is there a way to stop the spin on click of a button. Can't seem to get it to stop. Any help would be greatly appreciated.