|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
dynamic text fields and eval
I'm trying to create a dynamic text field inside of a movie clip and I can't solve this one: I can create and populate the text of the movie clip as follows:
Code:
myMovieClip.createTextField("myTextField",50,10,50,550,25);
movieClip.myTextField.text = "hello world";
The problem comes when the name of the text field is dynamic, because I'm creating multiple fields. If the textfield is not inside of the mc, this code works: Code:
var name = "myTextField"; _root.createTextField(name,50,10,50,550,25); eval(name).text = "hello world"; so here's the code that doesn't work: Code:
var name = "myTextField"; myMovieClip.createTextField(name,50,10,50,550,25); myMovieClip.eval(name).text = "hello world"; naturally, the last line is the one that doesn't work. How do I access that variable (myMovieClip.myTextField) ? Thanks! |
|
#2
|
|||
|
|||
|
It works to treat the elements of a movie clip as array elements, and access them with square brackets, so instead of using "eval", you would do the folowing (added to your code):
var name = "myTextField"; myMovieClip.createTextField(name,50,10,50,550,25); myMovieClip[name].text = "hello world"; |
|
#3
|
||||
|
||||
|
thanks, that was just the thing! One more
Now that I've got these in a movie clip, I would like to put them in a scroll pane. When I created the movieclip, I checked the export for actionscript option, and then I placed the pane on the page and set the scroll content to the name of the movie clip, but no luck. I'm not sure why it works when its just the movie clip but then not when its in the pane. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > dynamic text fields and eval |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|