Bullet-Proof TimelineMax Transitions Part 1: Jump To Section

by carl schooff on March 30, 2011 · View Comments

in GreenSock Tweening Platform Tips

This movie requires Flash Player 9

Here is an example of the first Bullet-Proof TimlineMax Page Transition. This technique allows you to jump directly to the beginning animation of any section/page you are introducing from any point in the timeline. This is the leanest and meanest of the three techniques I will be discussing. The video inside gives a thorough run down of the timeline animations we will be using in the other techinques. You don’t want to skip this one.

Watch the Video: File Setup and Jump to Section Explained

For an overview of all 3 techniques I will be covering please watch: Bullet-Proof TimelineMax Transitions Overview

File Basics

Each section’s artwork is contained in its own container clip: home_mc, blog_mc, portfolio_mc, and about_mc. Each movie clip lives on its own layer. This keeps your file very neat and easy to manage.

Each section in the timeline has specific labels marking where the animation starts and ends

//start the build of home
tl.addLabel("home_in", tl.duration);
tl.append(TweenMax.to(home_mc, 0, {alpha:1, immediateRender:false, onStart:setSection, onStartParams:["home"]}));
tl.appendMultiple(TweenMax.allFrom([home_mc.welcome_mc,
									home_mc.to_mc,
									home_mc.snorkltv_mc
									],
								   .8, {scaleX:0, scaleY:0, alpha:0, ease:Back.easeOut}, .4));
tl.append(TweenMax.from(home_mc.makeAwesome_mc, .5, {x:"-100", alpha:0}));

//this marks the end of the build sequence
tl.addLabel("home_complete", tl.duration);

//tweens that go between this section's _complete and the next section's _in dictate the animate out sequence for future techniques
tl.append(TweenMax.to(home_mc, .5, {alpha:0}));

tl.addLabel("blog_in", tl.duration);
//add rest of blog transitions...

The Meat

To introduce the home section we will ask the timeline to tween from home_in to home_complete like so:

tl.tweenFromTo("home_in", "home_complete");

Regardless of what the numbskull in the video was saying, it is imperative that we use TimelineMax.
TimelineLite does not have the tweenFromTo or TweenTo methods!

Being that we want to dynamically jump to various sections based on what buttons we pressed, the actual code will look like this:


//give each button a unique ID
nav_mc.navHome_mc.ID = "home";
nav_mc.navBlog_mc.ID = "blog";
nav_mc.navPortfolio_mc.ID = "portfolio";
nav_mc.navAbout_mc.ID = "about";

function navClick(e:MouseEvent):void
{
	//set targetSection based on the ID of the button you clicked
	targetSection = e.target.ID;

       //check to see that the button you clicked isn't the button of the currentSection you are in
	if (targetSection != currentSection)
	{
               //create a dynamic tweenFromTo
		tl.tweenFromTo(targetSection + "_in", targetSection + "_complete");

                //update currentSection
		currentSection = targetSection;

	}

}

Jump To Benefit
The main advantage of this Jump to Section technique is that its lean, mean and fast. No waiting between sections.

Stay Tuned

If you want to see how we can reverse-out a section build before going to the next section and/or play a unique out sequence you’ll want to see:

#2 Reverse Out Technique
Animation build sequence always plays backwards before going to next section. Reverse Out now live.

#3 Reverse Out with Custom Forward Out Technique
If a section is building, it will reverse out quickly before going to next section. If the section is fully complete a custom out animation will play. Watch Reverse Out with Custom Forward Out

Both these techniques can be viewed on the Overview/Teaser page: Bullet-Proof TimelineMax Transitions Overview

Download Flash CS4 Source

Investigate these files and feel free to alter the animations. Understanding the basic file setup will really help as we get into more intricate in/out transitions
SNORKLtv-jumpToSection CS4

More Resources

Check out my other TimelineMax Tutorials on Snorkl.tv.

Learn more about TimelineMax/Lite from GreenSock.

Read the Official TimelineMax Documentation to see all the cool stuff it is capable of.

Post to Twitter Post to Facebook

  • Snefer

    :D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

    yep I am THAT happy now.

  • http://www.snorkl.tv/ carl schooff

    Awesome!!!!

    My job is done!
    ;)

    Just wait til the next one. Its gonna be better.

    Thanks a bunch!

    Carl

  • snorklFan

    I just want to say thank you very much for all your excellent tutorials Carl , i have learned a lot about how to use tweenmax.

    Keep up the great work!

  • http://www.snorkl.tv/ carl schooff

    love hearing that. have a great night.

    Carl

  • Keir Sims

    Perfect!! This is definitely going to help me out on my current flash project.
    Thanks!

  • Neal

    This is a “nick of time” tutorial. Just when I’m working on my portfolio. Also this makes my workflow much simpler.

    One question? I’m trying go further and incorporate the fade/hide rollover tutorial you did to the boxes in the portfolio page to make them interactive.

    I use the same functions and loops you used in that tutorial, but I am getting a weird behavior. I get no error, but it seems the buttonMode doesn’t seem to work and none of the rollovers are working properly. I’m sure there is a further step to make each page have interaction. Any suggestions?

  • Neal

    After deleting everything but the buttonMode line and evaluate. It looks as if some of the nested objects inside the mc are triggering the hand and some are not. Also the hand is triggering on the entire object. Just a portion of the object. Not sure where the source of this may be but if you or anyone have ever experienced this, please give solution.

  • http://www.snorkl.tv/ carl schooff

    Hi Neal,

    I didn’t account for interactivity but I now know what the problem is and that is that the other sections are sitting on top of portfolio with their alpha set to 0. These other sections are interfering with the portfolio elements. if you slam this code into the top of my fla from this post:

    portfolio_mc.addEventListener(MouseEvent.MOUSE_OVER, testOver)
    portfolio_mc.addEventListener(MouseEvent.MOUSE_OUT, testOut)

    function testOver(e:MouseEvent):void{
    trace(e.target);
    TweenLite.to(e.target, .5, {alpha:.2})
    }

    function testOut(e:MouseEvent):void{
    TweenLite.to(e.target, .5, {alpha:1})
    }

    addChild(portfolio_mc);

    it will work fine because portfolio_mc is now on the top of the display list.

    What I really should have done is used autoAlpha on each sections “fade out” animation so that the visible property would be set to false.

    Thanks for pointing this out!

    Carl

  • Neal

    I’m not home yet but that does make a whole lot of sense. The button hand seem to only catch where the next page content ended. Also I didn’t think of autoAlpha. I will try it when I get home. Thanks

  • Keir Sims

    I’m have some trouble building a website using this method. I’ve added a cusom scroll bar to a page, withing its movie clip container, but I can’t click on it. I even tried making a movie clip button, and that didn’t work either. Any ideas on what Im doing wrong??

  • http://www.snorkl.tv/ carl schooff

    Wherever you are using alpha to fade out a section use autoAlpha. That will set the visible property of all the sections to false and they will not interfere.

  • Keir Sims

    Thanks for the responce Carl.
    I looked at your autoAlpha tutorial, and your right this is what I need.
    But I’m having trouble implementing it.
    Sorry

    I’m importing the plugin like this:
    import com.greensock.plugins.*;
    TweenPlugin.activate([AutoAlphaPlugin]);

    Then I tried setting the “for” loop for the clips like this

    section_clips[j].autoAlpha = 0; – didn’t work

    so I’tried setting it to the complete transition like this

    tl.append(TweenMax.to(about_mc, .5, {autoAlpha:0})); – didn’t work either.

    Than you.

  • http://www.snorkl.tv/ carl schooff

    autoAlpha only works with tweens.

    In your loop do

    TweenMax.to(section_clips[j], 0, {autoAlpha:0})


    Make sure all other alpha tweens use autoAlpha instead.

  • Keir Sims

    Quick response!
    Thank you thank you Carl. This is a great help for me.

  • Neal

    Ok back with a new question for you Carl. Let’s see if I can explain this correctly (probably not). I am trying to recreate this rollover – http://www.files.riacodes.com/flash_colorful-menu/- using the same button navigation used in this tutorial. Only instead of using the code in the riacodes tutorial, I tried deleting the nav_mc event listener and then using old habits and doing the “over” and “out” gotoAndPlay label event listener nested in each button mc.

    Now it works fine except when I click it is now an undefined button event though it is still an e.target inside the nav_mc movieclip. Before I begin to decipher the riacodes tutorial and mix it with your navigation, do you have any quick fix suggestions because this nav is great except when one wants to introduce an alternate rollover effect?

    p.s. If this post is not clear, I will try again and explain my question or send you a link to my file if need be. Thanks always for the teachings. 

  • Neal
  • http://www.snorkl.tv/ carl schooff

    Neal, i’m a little lost. the riacodes link is not working for me.
    i’m away for the weekend, so I don’t have much time to dig into this.
    if you still have problems I’ll take a look at your files early next week. 

  • Neal

    Yea the first link didn’t edit right. I posted a second one above. I’ll post another one here. This is what my goal is but I haven’t done it the riacodes way yet. Just the way I described above. I’m going to try to mix this riacoder version with yours, but if you find a quicker work around, please tell.
    http://www.flashperfection.com/tutorials/Colorful-Animated-Menu-with-AS3-71721.html

  • Keir Sims

    I’ve gotten all three of your transitions techiniques to work, and love em, but I was playing around with this one again for a portion of a website I’m working on, and (I may have done something wrong, but can’t figure out what), but when you delete the transitions of the interior movie clips, to have a simple fade in effect, it stops it from working correctly, it doesn’t seem to jump to the “_in” and “_complete” sections appropriately.

  • Ann Ezzell

    Really nice tutorial – very close to what I need to do.

    One comment, though – I’m running 64-bit Windows 7 Home Premium – the typeface that you used in this tutorial is non-standard (and, from what I can tell, only available for purchase). I was able to substitute Verdana for it when opening the file, but I still had to resize HOME, BLOG, etc., to make them fit.

    I didn’t have this problem with a few of your other tutorials, so I was surprised to have it here. Is it because you were trying to duplicate the GreenSock home page movie?

  • http://www.snorkl.tv/ carl schooff

    Hi Ann,

    Thanks for watching and sorry for the trouble. Quite honestly, I usually
    don’t put much thought into the font I use but I guess I wanted this one to
    look a touch nicer and didn’t want to go through the trouble of breaking
    them all apart.

    -c

  • Sayo1337

    I’m trying to understand how the text is animated in the code. Do you have any tutorials on how you have done the animations to help me understand further?

blog comments powered by Disqus

Previous post:

Next post: