Jump to content
Search Community

Need help toggling my tween

vdubplate test
Moderator Tag

Recommended Posts

There is a prob an easy solution to this. I'm having a hard time finding the logic that I need.

So I have a window that needs to open and close on the click of a button. so first click window opens. Second click window closes.

 

This is what i think my code will kind of look like but doesn't work.

I don't know how to structure the logic.

can someone help me out?

 

import flash.events.MouseEvent;

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


container_mc.find_more_btn.addEventListener(MouseEvent.CLICK, myFunction);
function myFunction(event:MouseEvent):void
{   

   if(event.type == "Click"){
       TWEEN FORWARD
   }else if(event.type == "Click++"){
       TWEEN BACK
}

Link to comment
Share on other sites

I've attached a basic example

 

here is the code:

 

import com.greensock.*;
import flash.events.MouseEvent;


window.alpha = 0;
var windowShowing:Boolean = false;
var windowTween:TweenLite = TweenLite.to(window,.5,{alpha:1,paused:true});



toggle_btn.addEventListener(MouseEvent.CLICK, toggleWindow);

function toggleWindow(e:MouseEvent):void
{
//this makes windowShowing the opposite of what it is, if true then switches to false
       //if false then switches to true
windowShowing = ! windowShowing;

if (windowShowing)
{
               //do something to show your window
	windowTween.play();
}
else
{
               //do something to hide the window
	windowTween.reverse();
}
}

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