Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 1st, 2003, 02:17 AM
blatant's Avatar
blatant blatant is offline
World Domination
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: San Diego
Posts: 126 blatant User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 17 sec
Reputation Power: 6
Send a message via AIM to blatant
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!

Reply With Quote
  #2  
Old September 1st, 2003, 02:51 AM
ardivus ardivus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Provo, UT
Posts: 7 ardivus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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";

Reply With Quote
  #3  
Old September 1st, 2003, 09:55 PM
blatant's Avatar
blatant blatant is offline
World Domination
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: San Diego
Posts: 126 blatant User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 17 sec
Reputation Power: 6
Send a message via AIM to blatant
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > dynamic text fields and eval


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway