Jump to content
Search Community

Question: Visible within TimelineLite

stevemac test
Moderator Tag

Recommended Posts

Hi All,

 

I'm hoping someone out there can answer a question for me, I assume it's easy but I'm a new user of Greensock so I suck, any feedback is greatly appreciated, thanks.

 

Basically I want to know how to instantly turn a button on/off using tweenLite & timelineLite.

 

I'm using cs5 with as2.

My problem is that I have a fairly complex timeline animation which contains buttons that I want to be turning on and off throughout.

 

And my problem comes about when I'm using timelineLite and when I have a timeline that plays an animation and at the end a button appears.

 

At the start of the code I am turning the button off using the code

//Hiding button
TweenLite.to(button_instance, 0, {_visible:false});

...which seems to work...

 

Then later during the animation I am wanting to turn it on, so the line of code I'm using (and which is what is confusing me) is

timeline.append( TweenLite.to(button_instance, 0, {_visible:true}));

 

This doesn't work, having the timing set to '0' in that line causes the button to be turned on at the start of the animation, seemingly ignoring the code that was added at the start to hide the button.

Curiously, if I set this value to something like 0.1 then the timeline animation will play how I want.

 

The only problem with setting it to 0.1 is that the full animation is fairly complex and rolling over other buttons means that this split second delay will cause conflicts and all kinds of problems I won't go into.

And yes, I guess I could be setting the value to something like 0.00001 because there won't be enough time for the user to possibly trigger these rollover/button conflicts, but doing that just seems like sloppy code to me which I'd like to avoid.

 

I just assumed setting the time value to 0 would mean this button will turn instantly on.

Can someone explain why this won't work or am I just doing it all together wrong?

 

Again, any feedback would be greatly appreciated, thanks again.

 

Finally, I've broken the problem down into a small example file, which is here for dl: https://rapidshare.com/files/461446355/ ... estion.zip

Or just read the example code field below:

 

import com.greensock.*; 
import com.greensock.easing.*;
import com.greensock.plugins.*;

TweenPlugin.activate([VisiblePlugin]);

//Hiding button
TweenLite.to(button_instance, 0, {_visible:false});

var timeline:TimelineLite = new TimelineLite();
timeline.append( TweenLite.to(button_instance, 4, {_y:"-400"}) );

//displaying button
timeline.append( TweenLite.to(button_instance, 0, {_visible:true}));

Link to comment
Share on other sites

Hi stevemac, welcome to the Greensock forums!

 

Have you tried passing "immediateRender:false" into your vars?

 

Check out the Tweening Tips and Tricks here:

 

http://www.greensock.com/tweening-tips/

 

timeline.append( TweenLite.to(button_instance, 0, {_visible:true,immediateRender:false}));

 

Also, to save you some code, depending obviously on how the rest of your flash works, you could use a from Tween instead:

timeline.append( TweenLite.from(button_instance, 0, {_visible:false,immediateRender:false}));

Which would save you having to set the visibility of the button to false initially.

 

Also, have you seen the autoAlpha Plugin? It may be of use to you:

http://www.greensock.com/tweenlite/#plugins

This sets the visibility of an object as well as it's alpha in one go.

 

I hope this helps, let us know how you get on!

X10

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...