What’s the different between
var myObject : Sprite = new Sprite();
and
var myObject : Sprite = new MovieClip();
What’s the different between var myObject : Sprite = new Sprite(); and var myObject
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
MovieClips and Sprite are separate classes, albeit related to each other because MovieClip extends Sprite. As such, MovieClip has all the same capabilities that Sprite has, and it also adds more, mostly related to timeline animation (play(), stop(), gotoAndPlay(), addFrameScript() et c.)
Because MovieClip has all the same capabilities as Sprite, you can assign a MovieClip object to a variable typed as Sprite.
Sprite, however, does not share all of MovieClip’s functionalities, so this does not work the other way around:
If you want to know the inheritance chain for a particular class, check out the documentation, e.g. for MovieClip: . You can see that it extends Sprite, which in turn extends InteractiveObject, and so on.
In language-agnostic terms, this is called inheritance, one of the strengths of which is polymorphism.