Object expands the new method under the MovieClip object, and all the movie clips below it benefit automatically.
Expansion of the image method:
ActionScript does not have the syntax to flip a movie clip horizontally, now using a prototype to expand a method,
Movieclip.prototype.flipx=function () {
This._xscale=-this._xcale;
}
Any movie clip can use this method to flip horizontally.
Syntax: Movie clips. flipx ();
Control all the right image
When making a game, there are times when you want all of the movie clips to stop playing, and you can't use the For loop command to do so. If a movie clip is created dynamically, you should not use the above method.
All movie clips belong to the MovieClip object, using prototypes to create powerful ways to control all movie clips.
You can control all movie clips by using a For loop that accesses all of the movie clips underneath the MovieClip object.
MovieClip.prototype.stopall () =function () {
for (var I and this) {
This[i].stop ();
}
}
StopAll () is a custom method, this. refers to the MovieClip object, which, like an array, records all movie clips, using this[i] to control each movie clip.
2 Expansion of static objects:
Some objects cannot use the new syntax to create an instance, which is called a static object, and they cannot use the prototype extension method.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.