Skip to content

Instantly share code, notes, and snippets.

@narkeeso
Created November 4, 2008 22:24
Show Gist options
  • Save narkeeso/22236 to your computer and use it in GitHub Desktop.
Save narkeeso/22236 to your computer and use it in GitHub Desktop.
import gs.TweenMax;
import gs.easing.*;
// Begin XML Data Here
// Initialize Caption Number
var capNum:int = 0;
var caption:XML = <WORDS>
<CAP>This is caption 1!</CAP>
<CAP>This is caption 2!</CAP>
<CAP>This is caption 3!</CAP>
<CAP>This is caption 4!</CAP>
</WORDS>;
// Hidden Content Setup
main_content_2.nextFrame();
// References
var currentFrame1:int = main_content_1.currentFrame;
var currentFrame2:int = main_content_2.currentFrame;
var totalFrames1:int = main_content_1.totalFrames;
var totalFrames2:int = main_content_2.totalFrames;
var words:TextField = mc_words.words_txt;
// Animation Settings
var captionAnim = Elastic.easeOut;
var captionAnimLength = 1;
// Initial Stage setup
nav_bar_right.alpha = 0;
nav_bar_left.alpha = 0;
words.text = caption.CAP[0];
// Navigation Bar Left and Right
nav_bar_right.addEventListener(MouseEvent.MOUSE_OVER, onNavRollOver);
nav_bar_left.addEventListener(MouseEvent.MOUSE_OVER, onNavRollOver);
nav_bar_right.addEventListener(MouseEvent.MOUSE_OUT, onNavRollOut);
nav_bar_left.addEventListener(MouseEvent.MOUSE_OUT, onNavRollOut);
function onNavRollOver(evt:MouseEvent):void {
TweenMax.to(evt.target, 1, {alpha:.25});
}
function onNavRollOut(evt:MouseEvent):void {
TweenMax.to(evt.target, 1, {alpha:0});
}
// Code for navigation next slide
nav_bar_right.addEventListener(MouseEvent.MOUSE_DOWN, onNavClickNext);
function onNavClickNext(evt:MouseEvent):void {
if (main_content_1.x == 0) {
if (currentFrame1 == totalFrames1) {
stop();
} else {
main_content_2.x = -1230;
TweenMax.to(main_content_1, 1, {x:1230, alpha:0, onComplete:nextSlide1});
TweenMax.to(main_content_2, 1, {x:0, alpha:1});
function nextSlide1():void {
main_content_1.gotoAndStop(currentFrame1+=2);
}
TweenMax.to(words, captionAnimLength, {y:60, ease:captionAnim, onComplete:enterText1});
function enterText1():void {
capNum++;
words.text = caption.CAP[capNum];
TweenMax.to(words, captionAnimLength, {y:0, ease:captionAnim});
}
}
} else if (main_content_2.x == 0) {
if (currentFrame2 == totalFrames2) {
stop();
} else {
main_content_1.x = -1230;
TweenMax.to(main_content_2, 1, {x:1230, alpha:0, onComplete:nextSlide2});
TweenMax.to(main_content_1, 1, {x:0, alpha:1});
function nextSlide2():void {
main_content_2.gotoAndStop(currentFrame2+=2);
}
TweenMax.to(words, captionAnimLength, {y:60, ease:captionAnim, onComplete:enterText2});
function enterText2():void {
capNum++;
words.text = caption.CAP[capNum];
TweenMax.to(words, captionAnimLength, {y:0, ease:captionAnim});
}
}
}
}
// Code for navigation previous slide
nav_bar_left.addEventListener(MouseEvent.MOUSE_DOWN, onNavClickPrev);
function onNavClickPrev(evt:MouseEvent):void {
if (main_content_1.x == 0) {
if (currentFrame1 <= 1) {
stop();
} else {
main_content_2.x = 1230;
main_content_2.gotoAndStop(currentFrame1-=2);
if (currentFrame2 - 2 <= 1) {
main_content_1.gotoAndStop(1);
TweenMax.to(main_content_1, 1, {x:-1230, alpha:0});
TweenMax.to(main_content_2, 1, {x:0, alpha:1});
} else {
TweenMax.to(main_content_1, 1, {x:-1230, alpha:0});
TweenMax.to(main_content_2, 1, {x:0, alpha:1});
TweenMax.to(words, captionAnimLength, {y:60, ease:captionAnim, onComplete:enterText1});
function enterText1():void {
capNum--;
words.text = caption.CAP[capNum];
TweenMax.to(words, captionAnimLength, {y:0, ease:captionAnim});
}
}
}
} else if (main_content_2.x == 0) {
if (currentFrame2 <= 1) {
stop();
} else {
main_content_1.x = 1230;
main_content_1.gotoAndStop(currentFrame2-=2);
if (currentFrame2 - 2 <= 1) {
main_content_1.gotoAndStop(1);
TweenMax.to(main_content_2, 1, {x:-1230, alpha:0});
TweenMax.to(main_content_1, 1, {x:0, alpha:1});
} else {
TweenMax.to(main_content_2, 1, {x:-1230, alpha:0});
TweenMax.to(main_content_1, 1, {x:0, alpha:1});
TweenMax.to(words, captionAnimLength, {y:60, ease:captionAnim, onComplete:enterText2});
function enterText2():void {
capNum--;
words.text = caption.CAP[capNum];
TweenMax.to(words, captionAnimLength, {y:0, ease:captionAnim});
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment