# If Condition required

**URL:** <https://forum.kirupa.com/t/if-condition-required/317401>\
**Category:** Uncategorized\
**Created:** [December 19, 2010, 7:23am UTC](https://forum.kirupa.com/t/if-condition-required/317401 "2010-12-19T07:23:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![learner\_7n](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@learner\_7n](https://forum.kirupa.com/u/learner_7n)\
**Post date:** [December 19, 2010, 7:23am UTC](https://forum.kirupa.com/t/if-condition-required/317401/1 "2010-12-19T07:23:54Z")

</div>

Hi,

The following is the working code. I want to add an “If statement” to achieve the following result:

If the Panel1 is at the bottom of the page (y:750), then it goes upwards (y:150) when user clicks on Panel1\_btn, if it is already upwards (y:150) then it should goes downwards (y:750) when it is clicked on the same button. How to re-code it? The following is my code:

Panel1\_btn.addEventListener(MouseEvent.CLICK, clickHandler);  
function clickHandler(event:MouseEvent):void {  
var Panel1Tween:TweenMax = new TweenMax(Panel1, 6, {y:450, delay:1, ease:Strong.easeOut});  
}
