본문 바로가기

AS

Tween 클래스

Tween 클래스를 사용하면 타임라인에서 만든 트윈과 유사하게 스테이지에서 무비 클립을 손쉽게 이동하고 크기를 조절하며 페이드 인/아웃 효과를 적용할 수 있습니다.

예를 들어 스테이지를 가로질러 이동하는 무비 클립을 상상해 보십시오. 이때 여러분이 사용할 수 있는 옵션은 다음과 같습니다.

  1. 타임라인에 키프레임을 추가하고 키프레임 사이에 모션 또는 모양 트윈을 삽입할 수 있습니다.
  2. 움직이는 애니메이션 효과를 연출하려면 onEnterFrame 이벤트 핸들러에 몇 가지 코드를 작성할 수 있습니다.
  3. 주기적인 간격으로 함수를 호출하는 setInterval() 함수를 사용할 수 있습니다.
  4. 또는 easing 클래스와 함께 Tween 클래스를 사용할 수도 있습니다.

다음 목록은 Tween 생성자의 매개 변수를 보여줍니다.

obj: reference - the object which the Tween targets
prop: string - name of the property (in obj) that will be affected
func: function – the easing function that will be applied to the tween
begin: number - the starting value of prop; the initial value of the property
duration: number - the length of time of the motion; set to infinity if the value is negative or omitted
useSeconds: boolean - a flag specifying whether to use seconds instead of frames Tween (obj, prop, func, begin, finish, duration, useSeconds)

example:

import fl.transitions.*;
import fl.transitions.easing.*;
 
var myTween:Tween = new Tween(ball_mc, "x", Elastic.easeOut, 0, 300, 3, true);
or
var myTween:Tween = new Tween(ball_mc, "alpha", Strong.easeIn, 100, 0, 24, false);

* Tween 클래스에서 초 단위 대신 프레임 단위로 지속 시간을 설정하려면 마지막 매개 변수인 useSecondstrue에서 false로 변경합니다. 이 매개 변수를 true로 설정하면 Flash에서는 지정된 지속 시간을 초 단위로 측정하게 됩니다. Tween 클래스에서 초 단위 대신 프레임 단위로 지속 시간을 설정하려면 마지막 매개 변수인 useSecondstrue에서 false로 변경합니다. 이 매개 변수를 true로 설정하면 Flash에서는 지정된 지속 시간을 초 단위로 측정하게 됩니다.