Skip to main content
July 10, 2009
Question

Custom class extending MovieClip - constructor/assignment problem

  • July 10, 2009
  • 1 reply
  • 1623 views

Hello,

I've got a simple class:

package somepackage

{

import flash.display.MovieClip;


public class NewMc extends MovieClip
{
  public var myVar:String = "something";
}
}

And there is a question now: how can I assign a "real" MovieClip object to my created-class object?

I mean:

var realMc:MovieClip = new MovieClip();

var myMc:NewMc = realMc;

I think it should be possible, as the custom class extends the original class.

I tried myMc = realMc as MovieClip, but such conversion isn't allowed.

And one thing! I don't want to add the realMc object as the myMc child! This solution is obvious, but It's not what I want. My aim is to have a "first-level" MovieClip object just having additional parameters.

Any ideas will be appreciated

This topic has been closed for replies.

1 reply

Inspiring
July 10, 2009

I think you are wanting to change the export settings for the movieclip symbol in your library.

Set its class to NewMC and then in your timeline:

var realMC:NewMC=new NewMC();

July 10, 2009

Not exactly...

So maybe I will specify my question in other words:

is is possible to override a MovieClip's stage property, so that it does not have access to it? If I override the get stage() function in a custom class added to display and simply add a MovieClip to the custom class'es display, it still has access to the stage.

Inspiring
July 10, 2009

Are you meaning that you want to make your class the Document class?

Other than that I have no idea what you are talking about.