Syntax Problem for Adding MovieClips Dynamically From the Library onto the Stage

Hi guys,

I am trying to use the addChild method to add a MovieClip from the library onto the stage. I have a set of MovieClips with classes named: Definition1, Definition2, and so on… up to Definition12.

What I am trying to do is to write a function so that depending on the function parameter (which is a random number generated from 1 to 12), it will load different MovieClips starting with “Definition” followed by the random number. I have something like this but the syntax is incorrect. Can someone please correct me on my syntax? Thanks!!

private function attachDefinition(random:uint):void {
		var _definition:MovieClip = new ["Definition" + random.toString()];			
			this.addChild(_definition);
		}

look into getDefinitionByName()… in help (F1) - select AS 3.0, in the language and components reference > All Packages > flash.utils package > functions.

Hope this helps.

Works like a charm. Thanks!!!