Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Enthusiast ,
Jan 18, 2021 Jan 18, 2021

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.

 

373
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 18, 2021 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.

Translate
LEGEND ,
Jan 18, 2021 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.

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

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

 

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

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"

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