all groups > flash actionscript > july 2004 >
You're in the

flash actionscript

group:

xml and dynamically created text boxes?


xml and dynamically created text boxes? Deuce Bigs
7/20/2004 7:52:17 PM
flash actionscript:
ok i'd say i'm almost a senior-beginner level actionscripter. I'm about to try
and tackle an incredibly diffcult task for myself. i can get xml to display.
but i have three xml files. one has basically five rows of items. one has 8
rows and one has just 3 rows. three movie clips each one of course uses a
specific xml file. i want in the movie clip to dynamically create a box for
each row. does anyone know of a tutorial out there to show me that? can i
just use actionscript and xml or do i have to get into asp also? any help or
starting points would really be appreciated. i really want to do this to throw
myself right into the middle of it cause that's the best way i learn. thanks
alot!
Re: xml and dynamically created text boxes? Deuce Bigs
7/20/2004 8:46:23 PM
You assume correct. all three ase going to look the same. basically each xml
station node has title and description inside it. so basically when it's
called i want like a red box to pop up with the title and description in it and
then underneath it the next station to pop up with it's title and description
and so on. i'll look up those things you put down. do i have to create an
array to create and fill out the boxes? i'm just guessing i don't really know
but thanks so far.

Re: xml and dynamically created text boxes? Lord Yoda
7/20/2004 9:14:08 PM
You don't need to use asp at all. You say you can already get xml to
display, so all you need to know is that you need to loop through each
xml row and then create an object (I assume you mean text box) inside
each clip. Assuming you're using MX 2004, look up 'Creating text fields
at runtime' in the help. Otherwise search for the createTextField()
function.

[quoted text, click to view]
Re: xml and dynamically created text boxes? Lord Yoda
7/20/2004 9:33:36 PM
Continued from my previous post...

and if you were really clever, you'd create a base class that all three
clips inherit from. That way you'd only have to write the code once.
Alternatively, make sure that you write functions that can be called by
all three clips to save you having to write the code three times. I'm
assuming that even though the xml is different, the display will be the
same.

[quoted text, click to view]
Re: xml and dynamically created text boxes? Lord Yoda
7/20/2004 11:05:04 PM
You don't have to create an array, but if you do it simply means that
you can loop through all the boxes inside your clip AND you don't have
to change the code if you add lines to the xml file.

For example, here's some pseudo-code (not real code, just describes the
process in a code-like way);



while(still another xml row) {
get the next xml row
create a new textfield
store the textfield in the array of textfields
position the textfield
assign your xml data to the textfield

add an offset to the variable that holds the
x y coordinates of the next textfield
}

This will just keep going until there are no more xml rows. Like this,
you don't have to change your code if you add more xml rows.

Also, if you have to reposition your textfields or do anything to them,
you can do it in a loop - no code changes when you change the xml! It
all takes care of itself.



[quoted text, click to view]
AddThis Social Bookmark Button