Skip to content

Instantly share code, notes, and snippets.

@kellymredd
Created May 26, 2010 13:29
Show Gist options
  • Save kellymredd/414474 to your computer and use it in GitHub Desktop.
Save kellymredd/414474 to your computer and use it in GitHub Desktop.
function animReset(line)
{
play_sound = true;
animated = false;
startingLine = 0;
for(a=0;a<=line;a++)
{
if(page1.children[0].children[a].animating)
{
page1.children[0].children[a].stop();
}
page1.children[0].children[a].width = 1;
page1.children[0].children[a].opacity = 1;
page1.children[0].children[a].backgroundColor = 'none';
}
}
page1_play.addEventListener('click', function()
{
l = page1.children[0].children.length;
if(play_sound)
{
page1_sound.play();
if (page1_sound.isPlaying())
{
animated = true;
var dur = 5000;
// line 1 background animation
line1Anim = Titanium.UI.createAnimation();
line1Anim.width = 250;
line1Anim.duration = dur;
line1fade = Titanium.UI.createAnimation();
line1fade.opacity = 0;
line1fade.duration = dur;
// line 2 background animation
line2Anim = Titanium.UI.createAnimation();
line2Anim.width = 250;
line2Anim.duration = dur;
line2fade = Titanium.UI.createAnimation();
line2fade.opacity = 0;
line2fade.duration = dur;
// line 3 background animation
line3Anim = Titanium.UI.createAnimation();
line3Anim.width = 250;
line3Anim.duration = dur;
line3fade = Titanium.UI.createAnimation();
line3fade.opacity = 0;
line3fade.duration = dur;
// line 4 background animation
line4Anim = Titanium.UI.createAnimation();
line4Anim.width = 250;
line4Anim.duration = dur;
line4fade = Titanium.UI.createAnimation();
line4fade.opacity = 0;
line4fade.duration = dur;
// line 5 background animation
line5Anim = Titanium.UI.createAnimation();
line5Anim.width = 250;
line5Anim.duration = 5000;
line5fade = Titanium.UI.createAnimation();
line5fade.opacity = 0;
line5fade.duration = 5000;
if(animated==true)
{
page1.children[0].children[0].animate(line1Anim);
page1.children[0].children[0].backgroundColor = 'yellow';
startingLine = 1;
}
line1Anim.addEventListener('complete', function()
{
if(animated==true)
{
page1.children[0].children[1].animate(line2Anim);
page1.children[0].children[1].backgroundColor = 'yellow';
page1.children[0].children[0].animate(line1fade);
}
});
line2Anim.addEventListener('complete', function()
{
if(animated==true)
{
page1.children[0].children[2].animate(line3Anim);
page1.children[0].children[2].backgroundColor = 'yellow';
page1.children[0].children[1].animate(line2fade);
}
});
line3Anim.addEventListener('complete', function()
{
if(animated==true)
{
page1.children[0].children[3].animate(line4Anim);
page1.children[0].children[3].backgroundColor = 'yellow';
page1.children[0].children[2].animate(line3fade);
}
});
line4Anim.addEventListener('complete', function()
{
if(animated==true)
{
page1.children[0].children[4].animate(line5Anim);
page1.children[0].children[4].backgroundColor = 'yellow';
page1.children[0].children[3].animate(line4fade);
}
});
line5Anim.addEventListener('complete', function()
{
if(animated==true)
{
page1.children[0].children[4].animate(line5fade);
startingLine = 0;
// last line of copy so reset everything.
page1_sound.stop();
page1_play.title = 'Play';
animReset(4);
}
});
}
page1_play.title = 'Stop';
play_sound = false;
}
else
{
page1_sound.stop();
page1_play.title = 'Play';
animReset(4);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment