 |
 |
Calling Flash Actionscript Gurus!
|
 |
|
 |
|
Banned
Join Date: Sep 2003
Status:
Offline
|
|
I realize that there are proably better forums for Flash questions, but since I am always on MacNN, I figured I would ask here 1st.
I am trying to create a basic Fantasy Football draft application (mainly for 'show puroposes') and I need a push in the right direction My biggest issue is trying to figure out the best way to parse data between movie clips. I don't know if the best way is to use arrays, XML, or some other method.
Basically, there will be a list of football players that a participant can choose from. I want the person to be able to click on or drag his choice into his roster. I guess I want to be able to dynamically remove the player from the pool while parsing the name to a few different MC's
Any help or push in the right direction would be greatly appreciated!
Thank you in advance
Dan Brown
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: the intarweb
Status:
Offline
|
|
i'm fairly sure you'd use an array. that's what people generally use to program the deck of cards when they're making card games. and what you're doing isnae a million miles away from that. you have your deck [ie. list of players] and you want to let people take a card from the deck [ie. choose a player] or put a card back into the deck [ie. 'un-choose' a player]. i'm no flash guru [a mere tinkerer] but what i'd do would be:
set up my array of the players and their values [eg. 'name','cost','shooting rating','passing rating','scoring rating','defending rating' ... or whatever, for each player], like so...
Code:
_root.playerlist = ["john smith","100000","8","6","8","3","bill
bloggs","75000","2","6","3","9","fred white","50000","7","9","4","6"..... etc];
then if the user picks a player by name [store the name in "_root.playerchosen"], i scan through the array to find him and once i've got him i can read the values associated with him as i know they're the next 5 values stored in the array after his name....
Code:
for (var a = 0; a<_root.playerlist.length; a++)
{
if (_root.playerlist[a] == _root.playerchosen)
{
_root.playername = _root.playerlist[a];
_root.playercost = _root.playerlist[a+1];
_root.playershooting = _root.playerlist[a+2];
_root.playerpassing = _root.playerlist[a+3];
_root.playerscoring = _root.playerlist[a+4];
_root.playerdefending = _root.playerlist[a+5];
}
if i just want to grab all the names [eg. to form a list of the available players], i just loop through the array taking every sixth value [which are the names]...
Code:
for (var a = 0; a<_root.playerlist.length; a=a+5)
{
/// do something with _root.playerlist[a] - which will be a player's name ///
}
if you want to remove a player from the array when he's been selected, do a similar manouevre to the first example, only this time when you've found him in the list use array.splice(startIndex, deleteCount) to remove him [and his associated values]....
Code:
if (_root.playerlist[a] == _root.playerchosen)
{
/// remove chosen player and next 5 values [ie. his ratings] ///
_root.playerlist.splice(a,6);
}
if the user changes his miond about a player and 'un-chooses' him, put him back into the array with array.push()....
Code:
_root.playerlist.push("john smith","100000","8","6","8","3");
hope that makes some kinda crazy sense! 
|
|
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
Originally posted by m a d r a:
i'm no flash guru [a mere tinkerer]
i thought you were a tinker? or do you prefer pikey?
i just wanted my 6666th post to be a reply to one of your posts 
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: the intarweb
Status:
Offline
|
|
Originally posted by philzilla:
i thought you were a tinker?
me and my bloody typos!
congrats on the 6666th by the way. seems like only yesterday you were running round here wi a single figure postcount and the arse hanging out yer trousers, asking folk how to use simpletext. and look at you now!
[did you ever find out, by the way?]
|
|
|
| |
|
|
|
 |
|
 |
|
Banned
Join Date: Sep 2003
Status:
Offline
|
|
Originally posted by m a d r a:
[B]i'm fairly sure you'd use an array. that's what people generally use to program the deck of cards when they're making card games. and what you're doing isnae a million miles away from that. you have your deck [ie. list of players] and you want to let people take a card from the deck [ie. choose a player] or put a card back into the deck [ie. 'un-choose' a player]. i'm no flash guru [a mere tinkerer] but what i'd do would be:
Thank you. I am trying to muddle through it now, but I think I mildly understand!
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|