Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How could I create a 'party' array or code

Community Beginner ,
Aug 10, 2015 Aug 10, 2015

Hi,

I still have some problem thinking about my code and how I should do it. (Beginner here!)

The question is that I want to create a 'party' member code for 10 heroes or more with all separated stats.

I wonder if I should create an array that I send it everywhere or there is an another solution, like a temporary files that stock up and save.

The array should look like this:

lvl 1 of the array: Party section

lvl 2 of the array: name,xp,attack,defence, lvl of the character.

Exemple : [['rodolf',1300,3,4,78],['Baaaaa',1301,4,3,79],['mukmuk',103,2,3,80], etc...]

I know that I can pop when a character die or leave the party, but I feel that its not a good solution for all of this. Cause the party is a very active variable and can change a lot of times. So I need your help to guide me! Please!

Thank you for reading my problem and try to help me!

TOPICS
ActionScript
262
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 10, 2015 Aug 10, 2015

use an object:

var obj:Object={};

updateParty('rudolf',1300,3,4,78);

function updateParty(nameS:String,_xp:int,_attack:int,_defense:int,_lvl:int):void{

obj[nameS]={xp:_xp,attack:_attack,defense:_defense,lvl:_lvl};

}

function retrieveParty(nameS):Object{

return obj[nameS];

}

///////////////

// then if you want to retrieve the lvl of mukmuk, use:

trace(retrieveParty('mukmuk').lvl);

Translate
Community Expert ,
Aug 10, 2015 Aug 10, 2015

use an object:

var obj:Object={};

updateParty('rudolf',1300,3,4,78);

function updateParty(nameS:String,_xp:int,_attack:int,_defense:int,_lvl:int):void{

obj[nameS]={xp:_xp,attack:_attack,defense:_defense,lvl:_lvl};

}

function retrieveParty(nameS):Object{

return obj[nameS];

}

///////////////

// then if you want to retrieve the lvl of mukmuk, use:

trace(retrieveParty('mukmuk').lvl);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2015 Aug 10, 2015

Yeah its sound pretty good! I forgot that I could use object too! Thank you a lot

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2015 Aug 11, 2015
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines