I have a simple question,in the below example when i created a new TransitionManager and pass this as a parameter a error occured that says Implicit coercion this is type Class.Why i have to typecast the Object in order to work,i thought object becomes a MovieClip after it extends it.
package {
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Border extends MovieClip
{
var trManager:TransitionManager = new TransitionManager( MovieClip(this) ); //<--
public function Border( ) {
}
public function doRotate ( ev : MouseEvent)
{
trManager.startTransition({type:Rotate, direction:Transition.OUT, duration:3, easing:Strong.easeInOut, ccw:false, degrees:90});
}
}
}
It seems like you stumbled across a strange oddity in the Flex compiler.
For a while, it seemed like the
thisreferred to the static class type, but I was wrong, it seems to be just a bug in the compiler, misinterpreting the type ofthisat compile time.I wouldn’t recommend using this approach though, as the members will be initialized before the constructor is called. Have a look at this example:
and the obvious answer is:
If the constructor was actually suppose to do some real initializations, you would actually use it uninitialized.
In conclusion, keep it simple, move the field initialization in constructor, that’s what they are for anyway.