Skip to main content
chenjil43641795
Legend
January 18, 2021
Answered

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

  • January 18, 2021
  • 1 reply
  • 440 views

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.

 

    This topic has been closed for replies.
    Correct answer Colin Holgate

    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.

    1 reply

    Colin Holgate
    Colin HolgateCorrect answer
    Inspiring
    January 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.

    chenjil43641795
    Legend
    January 19, 2021

    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"