Groups | Blog | Home
all groups > flash actionscript > march 2005 >

flash actionscript : Dynamically created text field issues


fasterthanlight
3/24/2005 11:39:01 PM
Ok, so, a client of mine needs an image viewer application to be created. What
I need to do is create movieclips on the go depending on a variable loaded from
the database textfile. For example, if the variable was 4, then only four
movieclips would be created. Now, these movieclips need to load an image
depending on the number the movieclip is. Movieclip number 3 would load 03.jpg.
This is all fine, no issues there. Here's where it gets tricky. In the same
database, caption information that needs storing. each image has its own
caption that also needs to get loaded into the movieclip, but inside a text
field. My question is, is there a way to change the variable name depending on
which movieclip its in? Example, the textfield inside movieclip number 4's
variable name has to be caption4.
rlc5611
3/25/2005 12:43:29 AM
Yes you can do that for(var ivar = 0; ivar <=4....
this.createEmptyMovieClip('clipname'+ivar,.....
this['clipname'+ivar].createTextField('caption'+ivar...... but why would you
want to do that? Once it is inside a unique movie clip, for me anyway, it
makes it much simpler to give everything the same name (i.e. 'caption' instead
of 'caption' + ivar). It is a lot easier and they can't be confused with each
other because they are each in a separate timeline.
fasterthanlight
3/25/2005 2:18:28 AM
ok, so this is how i want the end product laid out. On the stage is one
instance of an empty movieclip that the thumbnails are loaded into. This
movieclip is then duplicated depending on a variable that is loaded in from a
databse. the variable is just how many thumbnails are present on the server's
directory. So, now that the movieclip's are duplicated, it is imperitave that
they have unique instance names so that I can effectively load the different
thumbnails into the correct empty movieclip.
Now, each thumbnail has its own unique caption. The caption variable names all
have to be different or else one caption title will be loaded into each
thumbnail caption box.
The problem I am running into is naming both the movieclips and the textfields
while im duplicating.
In plain english, this is what I'm trying to achieve:

On load, determine how many times to duplicate the movieclip.
duplicate the movieclips
assign each movieclip its own unique instance name
create a textbox inside each movieclip and give it a variable name.

Any help is greatly appreciated.
fasterthanlight
3/25/2005 2:20:05 AM
AddThis Social Bookmark Button