I tried to ask this question here, but couldnot get a satisfactory answer. (Why should compiler allow super-class of a parameter in a function) Trying to ask again. Why casting, doesnot loose the member functions, when done on classes ? In the following, i expected, that after casting to Sprite, the class should loose all it's information regarding the current frame. But it retains the information, as if casting is just a "show-off", not "actually done" internally ?
import flash.display.MovieClip;
import flash.display.Sprite;
var mc:MovieClip
mc.gotoAndStop(2);
trace(mc.currentFrame); // output 2 --> that's ok
var sprite:Sprite = Sprite(mc)
trace( MovieClip(sprite).currentFrame);//output 2, value not lost, which is questionable
Output: 2 2
I know, the answer can be, it's how Adobe did it. But what's the logic ? Ideal logic should be that, after casting, and recasting, all the values must be restored to default. ( '0' in this case )
V.