I have been learning a few dynamic text animations and was fiddling with one particularly.
Heres the code…
[AS]function transition(chars, startX, startY) {
// initialize the text format object which we
// will be using to define the character spacings…
mFormat = new TextFormat();
mFormat.font = “Arial Black”;
mFormat.size = “32”;
// Assign the initial value of startX to a
// new variable because we would otherwise
// overwrite this important value…
startText = startX;
// Create a text field per character…
for (i=0; i<chars.length; i++) {
// create an empty clip…
name = “char”+i;
this.attachMovie(“character”, name, depthCount);
// put it at the appropriate place…
this[name]._x = startX+startText;
this[name]._y = startY;
// write the character into the clip textfield…
this[name].field.text = chars.substr(i, 1);
// get this text’s width and update the spacing…
mSize = mFormat.getTextExtent(this[name].field.text);
startX += mSize.width-3;
// update depth…
depthCount++;
// set alpha to zero and resize in preparation
// for the effect, and then add the event handler
// to trigger the start of the animation…
this[name]._alpha = 0;
this[name]._xscale = this[name]._yscale=1000;
this[name].timing = (startX-startText)/10;
this[name].onEnterFrame = starter;
}
}
function starter() {
// Stagger the start of the effect depending
// on the position of this character in the text…
this.timing–;
if (this.timing<0) {
this.onEnterFrame = animate;
}
}
function animate() {
// Scale and fade in until the
// text is back to its original alpha…
this._xscale -= 90;
this._yscale -= 90;
this._alpha += 10;
if (this._alpha>90) {
this.onEnterFrame=animate2;
}
}
//my code from here
function animate2 (){
myinterval=setInterval (this.onEnterFrame=animated,5000);
}
function animated() {
this._xscale += 90;
this._yscale += 90;
this._alpha -= 10;
if (this._alpha<0) {
this.onEnterFrame =undefined;
clearInterval;
}
}[/AS]
I pretty much get it all and i want to have the effect reversed after a set amount of time, my initial idea was to use set interval (as above) but if you test it out what happens is that the fucntion called ‘animate2()’ calls the animated function too soon and the set interval thing doesnt seem to effect it ??
With set interval will it call that function on 0 seconds and then every 5 seconds??
does the function get called immediately by the set interval and if so how can i make it only happen after about 5 seconds.
Or is their another way i could get it to slow down the out animation ??