Skip to main content
January 31, 2013
Answered

Duplicate movieclip you dynamically made

  • January 31, 2013
  • 2 replies
  • 455 views

Gidday

I have a class that has this above the constructor...

public var mc:MovieClip = new MovieClip();

... and a later fucntion gives it some graphics etc

In another function later on, I want to make duplicates of 'mc' with different names, but am getting the error:

1046: Type was not found or was not a compile-time constant: mc.

var copies:int = 10;

                var y:int = 0;

               

                for(var i:int = 0; i < copies; i++)

                {

                    var clone:mc = new mc(); //  <<<<   error occurs here

                    clone.name = 'clip' + i

                    clone.x = 0;

                    clone.y = y+10;

                    addChild(clone);

                }

Why does var clone not recognise mc?

I guess my question is - how do you make copies of a dynamically created movieclip (as opposed to one linked from the IDE library in Flash Pro)?

Cheers guys

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Ned Murphy

To create another jusat like it you do exactly what yiou did in the first place... create a MoveClip instance and fill it with the same content that  you filled the first one with.  

While you are trying to treat "mc" as a class,  "mc" is not a class, it is a MovieClip instance.

2 replies

Ned Murphy
Ned MurphyCorrect answer
Legend
January 31, 2013

To create another jusat like it you do exactly what yiou did in the first place... create a MoveClip instance and fill it with the same content that  you filled the first one with.  

While you are trying to treat "mc" as a class,  "mc" is not a class, it is a MovieClip instance.

February 4, 2013

Thank you Ned. You poor buggers - I go for months without questions sometimes, and then drown you guys in them - you're a bunch of champions.