Jump to content
Search Community

MovieClip deforms on reverse

giannosfor test
Moderator Tag

Recommended Posts

I wrote this piece of code,if I click a movieclip with base class the below,it zooms and flips concurrently.The code works perfect but when i remove the easing or add a listener to it etc if I chance something that has to do with the tween,at reverse the movieclip deforms the height

package Scripts 
{
import flash.display.MovieClip;
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent; 
import flash.text.*;
import fl.transitions.easing.*;

import com.greensock.*;

public class Part extends MovieClip {

	private static var flag : Boolean = true;
	private var tween : TweenMax;

	public function Part( )		
	{
		this.buttonMode = true;	
		addEventListener( MouseEvent.CLICK , doAnimate );
	}
	private function doAnimate( ev : MouseEvent )
	{
		if ( flag ) {
			parent.setChildIndex(this , 3);
			tween = new TweenMax( this , 2 , {  scaleX : 1.25 ,scaleY : 1.25
						, x : 400 , y : 300  , rotationY : 360 , rotationX : 360 
								, ease : Regular.easeOut } ); <-- When i remove the ease or use None.easeOut the mv deform
		} else {
				tween.reverse( );
			}

		flag = !flag;
	}
}
}

Link to comment
Share on other sites

I tested your code. it worked fine.

 

where you will run into problems is if you click on the object a lot while the tween is in progress.

 

let's simplify it:

 

assume the clip starts with an x of 0.

 

 

 

the first time you click a tween is created that tweens from 0 to 400.

 

TweenMax.to(this, 4, {x:400, ease:Linear.easeNone});

 

wait until the tween finishes.

 

click again and that tween will reverse.

 

if you click again 3 seconds into the reverse, the clip will have an x of 100

 

and then a new tween will be created that tweens from 100 to 400 and not 0 to 100.

 

----

 

the problem is that you are creating a new tween every other time you click.

 

you probably want to create one tween, and simply toggle playing it and reversing it.

 

so declare tween outside of your doAnimate() method.

 

make sense?

Link to comment
Share on other sites

Makes perfect sense I'll try it and see if I have any results.I know you don't get the desirable results when you double or triple click the movieclip,I was trying to fix first the above issue that I mentioned and then come up a solution for this.But maybe the answer is same for both.

I'll try it and see.

Just to mention in my fla file the only thing that I got is 4 squares which I convert them to movieclips and attached them with thie above base class.

Link to comment
Share on other sites

No nothing changed still deforms the movieclips,here is the link with the fla file and the class http://www.mediafire.com/?r2ii9icxdgy27jg

I have commented the addlistener if you remove the comments or change the easing type you will see the deform.

 

I have an other question.

package Scripts
{
import flash.display.MovieClip;
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent; 
import flash.text.*;
import fl.transitions.easing.*;

import com.greensock.*;
import com.greensock.events.*;

public class Part extends MovieClip {

	private static var flag : Boolean = true;
	private var tween : TweenMax;

	public function Part( )		
	{	
		tween = new TweenMax( this , 2 , {  scaleX : 1.25 ,scaleY : 1.25
						, x : 400 , y : 300  , rotationY : 360 , rotationX : 360 
								, ease : Regular.easeOut } );
		tween.pause( );
		this.buttonMode = true;	
		addEventListener( MouseEvent.CLICK , doAnimate );
	}
	private function doAnimate( ev : MouseEvent )
	{
		if ( flag ) {			
			parent.setChildIndex(this , 3);
			tween.restart( );
		} else {
				tween.reverse( );
			}	
		flag = !flag;
	}
}
}

Is this the only way to create one tween and don't make it start instantly?

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