I think i have the most common actionscript error.In the code below i have a MovieClip with some TextFields inside and i want to animate them.When i assign the class to the MovieClip i get this error 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.text:TextField.. When i trace the childs i get [Object TextField] and the code works fine if i place it on the first frame and apply it to a Dynamic Text so why i get this error when i try to apply this code to the childs of a MovieClip ?
Is there a chance to have forgot to import any necessary library ?
I have made the TextFields dynamic,i have embed the characters and set anti-alias for animation.
package AScripts
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import com.greensock.*;
import com.greensock.easing.*;
import flupie.textanim.*;
public class TextFade extends MovieClip {
private var child : Object;
public function TextFade( )
{
/* for (var i : int = 0; i < numChildren; i++ ) {
child = getChildAt( i );
trace( child );
*/
child = getChildAt( 0 );
var txtanim:TextAnim = new TextAnim( child ); // <-- Error
/* TextAnim expects a TextField as argument */
txtanim.mode = TextAnimMode.RANDOM;
txtanim.split = TextAnimSplit.WORDS;
txtanim.effects = myEffect;
txtanim.start();
}
function myEffect( block:TextAnimBlock ) : void
{
TweenLite.to( block , .5 , {alpha : 0 , delay : Math.random( ) * 1 } );
}
}
}
UPDATE : I made the suggestion changes and worked.
import flash.text.*;
private var child : TextField;
child = getChildAt( i ) as TextField;
Try this: