Jump to content

Create Labels by user input


music_lp90

Recommended Posts

Hi, I would like to have an input box that allows the user to type a word into the box then click on a button and have a movieclip created that contains whatever text the user typed into the input box. I know how to dynamically create a shape that's a movieclip, but I'm not sure how I can create dynamic text that's a movie clip.Any help would be greatly appreciated.Thanks!

Link to comment
Share on other sites

Create a new movie clip object (you don't need to convert a shape, just create an empty movie clip), then create a new text field and add it to the movie clip. I think you actually create the new text field on the new movie clip, e.g. new_mc.createTextField (not sure if that's the correct method, check the reference in Flash).

Link to comment
Share on other sites

Thanks Justsomeguy, I'm having trouble getting the text field to be inside of the movie clip, though.Here's what I've got:

mc_kitchen.onPress = function() : Void {	$i++;	$dynamicName = "label" + $i;	labeler($dynamicName, $i);}function labeler(dynamicName, layer){	this.createEmptyMovieClip(dynamicName, layer);	dynamicName.createTextField("my_txt", 1, 100, 100, 300, 100);	my_txt.multiline = true;	my_txt.wordWrap = true;	my_txt.text = "This is my first test field object text.";}

Thanks for your help.

Link to comment
Share on other sites

dynamicName.createTextField("my_txt", 1, 100, 100, 300, 100);dynamicName is not a reference to a movie clip, it's a string that contains the instance name. You'll need to get a reference to the movie clip. Since you're creating the movie clip on the this object, you should be able to use that to get a reference to it.mc = this[dynamicName];Ormc = eval("this." + dynamicName);

Link to comment
Share on other sites

Thanks, Justsomeguy, I've got it working now. I stopped using "this", because I didn't really understand how to use it, I was just guessing, but you helped me to understand better about making the correct reference.So it works like this:

mc_kitchen.onPress = function() : Void {	$i++;	$dynamicName = "label" + $i;	labeler($dynamicName, $i);}function labeler(dynamicName, layer){	var a = createEmptyMovieClip(dynamicName, layer);	a.beginFill(0xff0000, 50);	a.moveTo(0, 0);	a.lineTo(100, 0);	a.lineTo(100, 100);	a.lineTo(0, 100);	a.lineTo(0, 0);	a.endFill();	a.createTextField("my_txt", 1, 0,0,100,100);	a.my_txt.multiline = true;	a.my_txt.wordWrap = true;	a.my_txt.text = "This is my first test field object text.";	drag(a);	drop(a);}

Thanks!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...