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

  • Home
  • SEARCH
  • 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 8744141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:47:56+00:00 2026-06-13T11:47:56+00:00

I have a custom class that extends MovieClip . The idea is that it

  • 0

I have a custom class that extends MovieClip. The idea is that it allows for storing extra variables and information about the MovieClip.

public class MapObject extends MovieClip
{
    private var cellX:int;
    private var cellY:int;

    public function MapObject()
    {
    }
 }

I have several MovieClips (.swf files) that I load at runtime. The problem is, how can I make these MovieClip objects actually become MapObject objects?

I’ve tried :

var mapObject:MapObject = myMovieClip as MapObject;

but it gives null

PS. I know you can add variables dynamically to MovieClips, but I don’t really want to do that.

  • 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-06-13T11:47:57+00:00Added an answer on June 13, 2026 at 11:47 am

    You can’t change the class hierarchy without changing the code. You would have to go in each class definitions to change the parent class to MapObject instead of MovieClip.

    There is an easy and clean solution which consists in using a decorator:

    public class MapObject {
    
        private var mc:MovieClip;
        private var cellX:int;
        private var cellY:int;
    
        public class MapObject(mc:MovieClip) {
            this.mc = mc;
        }
    
        public function get movieClip():MovieClip {
            return mc;
        }
    }
    ...
    
    var wrapper:MapObject = new MapObject(new MyMovieClip());
    ...
    
    container.addChild(wrapper.movieClip);
    

    It’s a wrapper that takes an instance of another class (in your case MovieClip) to add functionality. It’s very powerful because you don’t have to go and change each of your subclasses any time you change MapObject. This principle is called composition over inheritance.

    In your case, all methods and properties of MovieClip are public so you would just write mc.play() instead of this.play().

    See the details about the Decorator design pattern.

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

Sidebar

Related Questions

I have a custom-made view that extends the View class. I would like 2
I have a custom class that extends Preference that I'm using in conjunction with
I have a custom class called NoteView that extends FrameLayout . Previously, I had
I have a custom class that extends the in built WPF Canvas called VisualCanvas
Hi I have a custom class that extends Sprite, that controls positioning on the
I have a custom View class that extends Spinner. I'm trying to figure out
I have a custom button class called ImageButton that extends JButton. In it i
I have a class that extends JButton because the custom look and feel I'm
I have custom class that extends WebViewPage that I use as the base for
I have my custom class that extends TEdit: TMyTextEdit = class (TEdit) private fFocusNextOnEnter:

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.