Jump to content
Search Community

Tweening Boolean value

timteka test
Moderator Tag

Recommended Posts

Hi, guys, couldn't find the answer on the forum. is there any way to tween (trigger) boolean value? e.g. i have and a sprite on stage (AS3) and what to hide and show it several times. Of course i can tween the object's alpha, but it would be much more effective to tween just visibility. for example:

var tw_circle:TweenMax = new TweenMax(mc_circle, 3, {repeat:5, visible:true});

Link to comment
Share on other sites

You could either make your own plugin for that or use an onUpdate like this:

 

mc.alpha = 0;
var tw_circle:TweenMax = new TweenMax(mc, 1, {repeat:5, alpha:1, onUpdate:updateVisible, ease:Linear.easeNone});
function updateVisible():void {
mc.visible = Boolean(mc1.alpha > 0.5);
mc.alpha = 1;
}

 

I'm just using alpha as a tool to determine the visible Boolean value, but I set it back to 1 each time, so visually the alpha won't actually change. You could do this with a generic object instead, but hopefully this demonstrates the concept okay.

Link to comment
Share on other sites

didn't understand your answer concerning alpha, but thank u very much for the idea, 'cos TweenMax is working even without setting implicit tween params:

tw_circle = new TweenMax(circle, .3, { repeat:3, onComplete:doSmth, onUpdate:function():void{ circle.visible = !circle.visible; } } );

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...