Skip to main content
Inspiring
June 10, 2011
Answered

Help! with tweens

  • June 10, 2011
  • 1 reply
  • 1015 views

I got this code and i whant to make it so unit moves smoothly to the destination i got told to seach key words like LiteTween and built in tween but i cant find anything that helps will someone help me.

unit.onRelease = function(){
_root.onMouseUp = function(){
unit._x = _xmouse;
unit._y = _ymouse;
delete _root.onMouseUp;
}
}

This topic has been closed for replies.
Correct answer kglad

my error.  use:


import mx.transitions.Tween;

import mx.transitions.easing.*;

unit.onRelease = function(){

_root.onMouseUp = function(){

var t1:Tween = new Tween(unit, "_x", Elastic.easeOut, unit._x, _xmouse, 3, true);

var t2:Tween = new Tween(unit, "_y", Elastic.easeOut, unit._y, _ymouse, 3, true);

delete _root.onMouseUp;
}
}

1 reply

kglad
Community Expert
Community Expert
June 10, 2011

:

import fl.transitions.Tween;

import fl.transitions.easing.*;

unit.onRelease = function(){

_root.onMouseUp = function(){

var t1:Tween = new Tween(unit, "_x", Elastic.easeOut, unit._x, _xmouse, 3, true);

var t2:Tween = new Tween(unit, "_y", Elastic.easeOut, unit._y, _ymouse, 3, true);

delete _root.onMouseUp;
}
}

Inspiring
June 10, 2011

is there any way to do this with out inporting stuff

is it possible to do it something like this

unit._x = _xmouse/3;
unit._y = _ymouse/3;

so it moves smothly because i get errors with the code you give me

kglad
Community Expert
Community Expert
June 10, 2011

what errors?  copy and paste.