Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : text list element as a button ?


PatomaS
4/20/2004 10:56:31 PM
Hello people...

I'm making a simple aplication in flash, and have a little problem.

I have a dinamic text box filled with data from an xml file. There is no
problem with this part of the animation.

The problem is:

I need that the each line in the text box could be clicable.

In deed, i need to show a layer with the detail of the line that the user
clics, but my problem is that i can't find the way to know wich element of the
text box is clicked.

May be ia have to use a listbox ?

If i use a listbox, can i know wich element is selected easily ?

There is another way to do what i want to do?

I supose that with the listbox is easier, but i want to try the other way (the
dinamic text box).

Please let me know your advices.

Thanks for your time and attention

:)

Bye
mandingo
4/21/2004 1:28:57 AM
I take it that you are creating these fields dynamically through some sort of
loop?

fieldsToCreate = ["First Field", "Second Field", "Third Field"];
for (var k = 0; k<fieldsToCreate.length; k++) {
this.createEmptyMovieClip(fieldsToCreate[k]+"_mc",k);
this[fieldsToCreate[k]+"_mc"].createTextField(fieldsToCreate[k]+"_txt",
100+k, 100, (50*k)+25, 200, 16);
this[fieldsToCreate[k]+"_mc"][fieldsToCreate[k]+"_txt"].text =
fieldsToCreate[k];
this[fieldsToCreate[k]+"_mc"].identifier = k;
this[fieldsToCreate[k]+"_mc"].onRelease = function() {
trace("You just clicked on "+this._name+" which is field
"+(this.identifier+1)+" and relates to array item "+this.identifier+":
"+fieldsToCreate[this.identifier]);
};
}


Paste that code into an actions layer... and click on one of the textFields...
the output should tell you what is happening

hope this helps
cheers,
PatomaS
4/21/2004 8:03:18 PM
:D

Hey, thank you very much for the help...

by now i'm making some tests with your code, but more important than your
exact code, is that you generate a new idea in my mind and i'm working on it
too...

:)

thanks...

:)

Bye
mandingo
4/21/2004 10:53:52 PM
No problems,

Good Luck
AddThis Social Bookmark Button