How to add a method to a movie clip(H5)

Enthusiast ,
Jan 18, 2021

Copy link to clipboard

Copied

I'll use arrays.

Like what:

var sz=[this.mc0,this.mc1]

Array.prototype.myUcase=function(){
xs=0.1
for (i=0;i<this.length;i++){
this[i].x=100
}
}

sz.myUcase()

 

But I don't know 

How 

Add a method to a movie clip

 

 

lib.prototype.myUcase=function(){
this.x=100
}

this.mc1.myUcase()

This operation fails.

It bothers me.

 

Views

75

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Adobe Community Professional , Jan 18, 2021
Colin Holgate Adobe Community Professional , Jan 18, 2021
The approach looks like an ActionScript 1 or 2 way of doing things. With ActionScript 3 you could do this: var sz=[this.mc0,this.mc1]; for (i=0;i<sz.length;i++){ sz[i].x=100; } sz.push(new MyCustomMC() as MovieClip); sz[sz.length-1].x = 100; 'MyCustomMC' would be a movieclip in your library where you had set its linkage name to MyCustomMC. Saying 'as MovieClip' would make your custom movieclip act like a normal one.

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Jan 18, 2021

Copy link to clipboard

Copied

The approach looks like an ActionScript 1 or 2 way of doing things. With ActionScript 3 you could do this:

var sz=[this.mc0,this.mc1];

for (i=0;i<sz.length;i++){

sz[i].x=100;

}

sz.push(new MyCustomMC() as MovieClip);

sz[sz.length-1].x = 100;

'MyCustomMC' would be a movieclip in your library where you had set its linkage name to MyCustomMC. Saying 'as MovieClip' would make your custom movieclip act like a normal one.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Enthusiast ,
Jan 18, 2021

Copy link to clipboard

Copied

I'm sorry

I don't speak English well

I'm learning HTML5

Use animate cc

I'm looking
https://www.w3schools.com/js/js_object_prototypes.asp

JavaScript Object Prototypes

 

Array objects inherit from Array.prototype

I wrote the first one in ANIMATECC.

But

How movie clips use prototypes, and I won't rewrite them in Animatecc

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
chenjil43641795 AUTHOR LATEST
Enthusiast ,
Jan 18, 2021

Copy link to clipboard

Copied

Hi, I already know how to use it.

Thank you for your answer

Object. is a method that you can add to a movie clip

It's just that "THIS" is wrong.

I'm going to adapt my habits
Use "exportRoot." in "ANIMATECC." Instead of "THIS"

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more