0
votes

So here I have created a MovieClip symbol of the name devTextMC. I have linked my .fla file to a (document) class of the name supportForce and I execute all the code from it. However, I am unable to make any reference to the devTextMC from inside supportForce. For example-

addChild(devTextMC);

Gives an error 1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject. I have a slight idea of what to do here, that is, to declare a variable or something, but I'm not sure.

I am very sorry if the question is unimportant, but I need it clarified. Thanks in advance.

1
You have to create an instance of your devTextMC class which you can use like this : var instance:devTextMC = new devTextMC(); addChild(instance);.akmozo

1 Answers

0
votes

devTextMC is a class, whereas the thing you want to add to the stage is an instance of a class. If you're not sure what this means, have a read about object oriented programming.

Basically, devTextMC is what you use to make symbols, but it's not the symbol itself. The way you create a symbol is by using the new keyword:

new devTextMC();

so, a simple way to get this to work is to replace your line of code with

addChild(new devTextMC());

if you want to keep track of this symbol, you can use a variable. Then you can do things like

var instance:devTextMC = new devTextMC();
addChild(instance);
instance.x = 100;
instance.y = 50;