Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:27:30+00:00 2026-05-16T05:27:30+00:00

In a ActionScript 2 code sample it uses some MovieClip.prototype’s functions, as MovieClip.prototype.setModel; I’m

  • 0

In a ActionScript 2 code sample it uses some MovieClip.prototype’s functions, as MovieClip.prototype.setModel;

I’m trying to write this example using an ActionScript 3 class, but the MoviewClip.prototype does not exists, where can I get it from? Does it exist in ActionScript 3?

–update

Ok, as you are asking, here goes, this code works just fine as an ActionScript included on frame1, but I want to make a ActionScript 3 class with this same code:

//package
//{
//  public class asteroids extends MovieClip
//  {

        var MW = 8;                     // Scaling factor for models (which were originally drawn on graph paper)
        var SW = Stage.width;           // Stage coords
        var SH = Stage.height;
        var kDegToRad = Math.PI/180;    // Useful constant for drawing circles & such
        var kDamp = 0.99;               // Damping in ship acceleration

        // The models
        //
        // Rocket fuselage
        var fuseModel = [{mx:0, my:-5.5, x:0, y:-4, pen:.5, clr:0x000033, alpha:50},
            {cx:-1,cy:-3,x:-1,y:-1, pen:2, clr:0x000033, alpha:50},
            {x:-.75,y:4},
            {cx:0, cy:4.5, x:.75,y:4},  // from -.75,4
            {x:1,y:-1},
            {cx:1,cy:-3,x:0,y:-4}];

        // Rocket fins
        var finModel = [ {mx:-1,my:-1,cx:-3,cy:4,x:-2,y:6,bf:0x0000FF,bfa:80},
            {cx:-1,cy:4.5,x:-.75,y:4}, 
            {x:-1,y:-1},
            {mx:.75,my:4,cx:1,cy:4.5,x:2,y:6},
            {cx:3,cy:4,x:1,y:-1},
            {x:.75,y:4,ef:1}
        ];

        // Routine to scale model to arbitrary size
        function scaleModel(m,s)
        {
            for (var i = 0; i < m.length; ++i)
            {
                var pt = m[i];
                if (pt.mx != undefined)
                {
                    pt.mx *= s;
                    pt.my *= s;
                }
                if (pt.cx != undefined)
                {
                    pt.cx *= s;
                    pt.cy *= s;
                }
                pt.x *= s;
                pt.y *= s;
            }
        }

        // Draw a model
        //
        function drawModel(m)
        {
            for (var i = 0; i < m.length; ++i) 
            {
                var pt = m[i];
                if (pt.bf != undefined)
                    this.beginFill(pt.bf, pt.bfa);
                if (pt.pen != undefined)
                    this.lineStyle(pt.pen,pt.clr,pt.alpha);
                if (pt.mx != undefined)
                    this.moveTo(pt.mx,pt.my);
                if (pt.cx != undefined)
                    this.curveTo(pt.cx,pt.cy,pt.x,pt.y);
                else if (pt.x != undefined)
                    this.lineTo(pt.x,pt.y);
                if (pt.ef != undefined)
                    this.endFill();
            }
        }


        // Ship Movement and most game-play stuff happens here
        function ShipMove()
        {

            // Steering & Thrust
            if (Key.isDown(Key.LEFT))
                this._rotation -= 5;
            else if (Key.isDown(Key.RIGHT))
                this._rotation += 5;
            if (Key.isDown(Key.CONTROL) || Key.isDown(Key.UP))
            {
                this.vx += Math.sin(this._rotation*kDegToRad);
                this.vy -= Math.cos(this._rotation*kDegToRad);
            }
            else if (Key.isDown(Key.DOWN)) 
            {
                this.vx *= .9;
                this.vy *= .9;
            }
            // Basic movement with acceleration and damping
            this._x += this.vx;
            this._y += this.vy;

            // Wrap around edges of stage
            if (this._x < -this._width)
                this._x += SW+this._width*2;
            else if (this._x > SW+this._width)
                this._x -= SW+this._width*2;
            if (this._y < -this._height)
                this._y += SH+this._height*2;
            else if (this._y > SH+this._height)
                this._y -= SH+this._height*2;

        }


        // Initialize new ship
        function NewShip()
        {
            ship_mc._x = SW/2;
            ship_mc._y = SH/2;
            ship_mc.onEnterFrame = shipMove;
        }

        // Assign a sprite model to a movieclip & draw it
        //
        MovieClip.prototype.setModel = function(m)
        {
            this.model = m;
            this.drawModel(m);
        }

        MovieClip.prototype.drawModel = drawModel;

        scaleModel(fuseModel, MW*.8); // Using a slightly smaller rocket than original drawing
        scaleModel(finModel, MW*.8);

        // One Time Initialziation
        //
        _root.createEmptyMovieClip("ship_mc", 2);
        ship_mc.createEmptyMovieClip("fuselage", 1);
        ship_mc.fuselage.setModel(fuseModel);
        ship_mc.createEmptyMovieClip("fins", 2);
        ship_mc.fins.setModel(finModel);

        NewShip();

//  }
//}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:27:30+00:00Added an answer on May 16, 2026 at 5:27 am

    You should probably extend MovieClip and add the new functionality to the subclass, it’s the best/proper way to go. Prototypes in AS2 are old, and were used when the language didn’t support true OOP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've not seen it, but perhaps that's a New UI?… May 16, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer I have been looking at a similar issue with Linq… May 16, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer If you cannot find how to take out the xammp… May 16, 2026 at 4:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I follow some sample code which uses trace(Hello World); to print out something in
Any sample ActionScript code on the net available ?
I'm trying to load HTML/CSS from an external domain into a SWF using Actionscript
I am using Adobe Flash CS4. I don't know why I do the sample
Is there any opensource flash/actionscript code to display an image for x number of
This is from ActionScript 2.0 not a big one, but enough to keep me
Why are inline closures so rarely used in Actionscript? They are very powerful and
How to open a Browser popUp window from Actionscript ( Flash )? ( Any
I've been asked to populate a flash file with some data from a database.
i want to add a SWF metadata tag to an ActionScript Project in Flash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.