Twitsnip is a place to post code snippets and share them. Login with your existing Twitter account, if you don't have a Twitter account simply create on at www.twitter.com

Motion tween with actionscript

Motion tween with actionscript

0

If you ever wanted to do a motion tween with actionscript this tutorial will be very useful. The actionscript goes in the frame. Make a button in my example I gave it an instance name of bt. make a movieclip of the item you want to tween give it an instance name in my example I have given it a name of a1

// button has an instance name of bt when it's pressed the tween is performed
	bt.onPress = function() {
	   // call function to do the tween
	   tweenFeat();
	}
	function tweenFeat() {
			easeType = mx.transitions.easing.Regular.easeOut;
	// define what type of tween to be used to see other tween effects visit http://www.oman3d.com/tutorials/flash/tweenclasseasing/
			var begin_x = 1061; // define where object is on stage _x
		  var begin_y = 144.3; // define where object is on stage _y
			var end_x = 531; // define where object will end on stage _x
		  var end_y = 144.3; // define where object will end on stage _y
			var time = 2;  // define speed
		  //putting it together
		  // new tween						your mc name
			featTween = new mx.transitions.Tween(a1, "_x", easeType, begin_x, end_x, time, true);
		  featTween = new mx.transitions.Tween(a1, "_y", easeType, begin_y, end_y, time, true);
	}

Tags: motion, tween

Comments

No comments yet

Login to Twitter to comment