PDA

View Full Version : MX: Tie effects to a dynamic textfield?



CEOofAEP
August 8th, 2005, 04:37 AM
Be greeted.

I am working on a flash file that dynamically displays data coming from (currently two) XML files on screen. I'm filling various text fields and adjusting colours based on startup parameters, etc. All that already works.

It's a live commentary display thing for any sort of sports game (currently focussing on soccer, though) and I have 1 big textfield for the live commentary (coming from one XML file) and various other smaller fields for the score, team names, scorer, etc. (coming from another XML file).

Now I have a question:
The content of, for example, the team statistics field is filled by functions that interpret the XML and come up with a list of the players and (if applicable) the goals they shot and the penalties (red and yellow card) they received.
Currently, for myself, I only put out the plain text- and the info for a player looks like this:
"02 Fahrenhorst [IN:27] [51] [22:Y]"the "02" is the shirt number, then the name, then when they were substituted ("IN" or "OUT" if appicable), when they shot a goal and when they received penalties (Y for Yellow, R for Red), all accompanied by the play time / minute.

I made a fancy little rotating soccerball, red and yellow cards and rotating green arrows that move on mouse-over (my boss wants it to be an "overkill" of bells and whistles)...

So here is the question, finally: is there a way to relatively easily apply / position those symbols after the player name?
I guess it's not possible to include MCs in an html formatted textbox (or is it?)- so it would have to be on an own layer... for that I guess I can retrieve the row that the players are in- but the exact length (width) of the name of the player might be a problem because I have to use a "_sans"-type font (and that makes it hard to know just how wide the player name really is / where to begin placing the symbols)...

I guess this is all a bit theoretical- what happens is this:
I have a function that loads the XML and distributes the data from it to various arrays (currently 7). Then, in the code, it checks which team is currently displayed and runs through a loop that fills the string for the textfield:

>> loop team (player ID)
_>> has been substituted? (if so, get & display replaced player ID instead)
_>> add to string: "shirt number", "name"
__>> if player was substituted, add "when".
____ (replaced player goes to a seperate array and field)
___>> if the player shot goals(s), add "when"
____>> if the player received penalties, add "when" and "type"
>> add a "<br>".
<< (next player)

All that stuff goes to a single string that is then sent to the text field.

So yea- any ideas on an easy way to position the symbols rather than the temporary text bits that I am using now? I am going to try and figure out a way myself but input is welcome :)

Thanks for your time and support!
~Marcel

CEOofAEP
August 8th, 2005, 09:26 AM
Forum post too long? ^^

amnos
August 8th, 2005, 09:49 AM
does the text box scroll or is it just a long list? If it does not scroll I would suggest breaking the big text box into a several small text boxes. Then create and position them while your running through the for loop. Position them by working off the previous ones position. Just attachMovie the arrow right after the name.

in psuedo code:


margin = 7;
posX = 0;
posY = 0;
for(x=0;x<teamLength;x++){
if(playerX == substituted){
getNewPlayer();
}
create textFieldName_Num and fill w/ text
place textFieldName_Num according to posX and posY
posX+= textFieldName_Num._width+margin;//increment posX accordingly

attachMovie of arrow
place arrow according to posX and posY
posX+= arrow._width+margin;//increment posX accordingly

create textFieldGoal_Pen_penType and fill w/ text
place textFieldGoal_Pen_penType according to posX and posY
posX = 0;//reset posX
posY += textFieldGoal_Pen_penType._height+margin;//increment posY accordingly
}


you can of course break the text boxes up in to whatever combonation I just made them big clumps.

CEOofAEP
August 8th, 2005, 10:24 AM
Awesome. Thank you. That's what I was working up towards, too :)

amnos
August 8th, 2005, 10:27 AM
np :battery: