A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: extends MovieClip ??

  1. #1
    Senior Front End Developper
    Join Date
    Dec 2000
    Location
    Montréal
    Posts
    568

    extends MovieClip ??

    How can I recreate the

    classname.prototype = new MovieClip();

    in AS2.0 ??


    Lot of people seems to do this
    Code:
    class className extends MovieClip
    {
        var m_mc:MovieClip;
    
         function className (_mc:MovieClip)
         {
              m_mc = _mc;
         }
    }
    but this isn't right since MovieClip actions need to be apply to the m_mc member instead of the class itself making the "extends MovieClip" useless.

    Is there a way for a class to really inherits from movieclip ??

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    you could use something like this,

    code:

    class ClassName extends MovieClip {
    function ClassName() {
    // use some methods inherited from MovieClip
    // draw a line using the drawing API
    this.lineStyle(1, 0x000000, 100);
    this.moveTo(0, 0);
    this.lineTo(100, 100);
    }
    }



    you can now associate a movie clip with this class either using Object.registerClass (as in MX) or by filling in the AS2 class name field in the linkage properties for the clip,

    code:

    Object.registerClass("myClip", ClassName);
    this.attachMovie("myClip", "myNewClip", 1); // myNewClip contains the line drawn using the drawing API


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center