var actInd = Titanium.UI.createActivityIndicator({ bottom:10, height:50, width:10, style:Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN }); function sleep(ms) { var dt = new Date(); dt.setTime(dt.getTime() + ms); while (new Date().getTime() < dt.getTime()); } counter = null; function animatedown() { sound = Titanium.Media.createSound({ url : "comp.mp3" }); sound.play(); actInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN; actInd.font = {fontFamily:'Helvetica Neue', fontSize:15,fontWeight:'bold'}; actInd.color = 'white'; actInd.message = 'Staring Scan'; actInd.width = 210; win1.add(actInd); actInd.show(); win1.add(horbar); horbar.show(); horbar.top = 1; function countdown(){ var current = horbar.top; current = current + 1; horbar.top = current; label1.text = current; } function countup(){ var current = horbar.top; current = current - 1; horbar.top = current; label1.text = current; } function countright(){ var current = vertbar.left; current = current + 1; vertbar.left = current; label1.text = current; } function countleft(){ var current = vertbar.left; current = current - 1; vertbar.left = current; label1.text = current; } while (horbar.top < 350){ sleep(5); countdown(); } actInd.message = 'Finding Tattoo'; while (horbar.top > 1){ sleep(5); countup(); } sound.play(); horbar.hide(); win1.add(vertbar); vertbar.left = 1; actInd.message = 'First Translation'; while (vertbar.left < 320){ sleep(5); countright(); } actInd.message = 'Finalising'; while (vertbar.left > 1){ sleep(5); countleft(); } vertbar.hide(); actInd.hide(); }