atmd
atmd

Reputation: 7490

New Tween not working correctly

A bit confused as to where Im going wrong here

I have a dynamic text field, called myText. Im running the below code:

package  {
import fl.transitions.Tween;
import fl.transitions.easing.Elastic;
import flash.display.MovieClip;
import fl.transitions.easing.*;
import flash.text.TextField;
import flash.text.TextFormat;


public class video extends MovieClip {


    public function video() {


        var fmt:TextFormat = new TextFormat();

        var letterTween:Tween = new Tween(fmt, "letterSpacing", Elastic.easeInOut, 6, 15, 2, true);

        myText.setTextFormat(fmt);



    }
}

}

I know its targeting the text as the text letter spacing is set to 6 when running, but nothing happens, I dont get me nice tween to 15 letter spaces(ing)

where am I going wrong?

thanks

Andrew

Upvotes: 1

Views: 273

Answers (1)

Neil
Neil

Reputation: 8111

The reason you don't see any updates is because when TextFormat properties change, you have to reapply the TextFormat. All you need to do is listen for updates from the Tween and apply it there.

My example was tested on the timeline in CS5, go ahead and amend your class accordingly.

import fl.transitions.Tween;
import fl.transitions.easing.Elastic;
import flash.display.MovieClip;
import fl.transitions.easing.*;
import flash.text.TextField;
import flash.text.TextFormat;
import fl.transitions.TweenEvent;

var fmt:TextFormat = new TextFormat();
var letterTween:Tween = new Tween(fmt, "letterSpacing", Elastic.easeInOut, 6, 15, 2, true);
letterTween.addEventListener(TweenEvent.MOTION_CHANGE, onMotionChanged);
myText.setTextFormat(fmt);

function onMotionChanged(event:TweenEvent):void{
    myText.setTextFormat(fmt);
}

Upvotes: 2

Related Questions