0

I'm trying to easily add in some dynamic attributes to a few variables that I construct at the beginning of my movie clip.

The variable is called with the line:

var clipToUse:CustomClip = new CustomClip();

I need to replace the CustomClip class (which is created in the library) with a variable that's changes earlier in the function. I tried setting a variable and then using the root[variable] command, which threw an error saying that a semicolon was expected on the right bracket.

I'm at my wit's end trying to get this custom class to be defined by a variable.

1
  • 1
    What you're looking for is getDefinitionByName. Commented Feb 2, 2015 at 8:11

1 Answer 1

1

You can try:

 var ClassName:Class = getDefinitionByName('CustomClip') as Class;

 //DisplayObject/DisplayObjectContainer/Sprite/MovieClip, the base class you are using in your CustomClip
 var clipToUse:DisplayObject = new ClassName();

 addChild(clipToUse);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.