# \[AS2\] Percentage based random choice

**URL:** <https://forum.kirupa.com/t/as2-percentage-based-random-choice/329679>\
**Category:** programming\
**Created:** [October 1, 2012, 11:22am UTC](https://forum.kirupa.com/t/as2-percentage-based-random-choice/329679 "2012-10-01T11:22:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverneo188](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@silverneo188](https://forum.kirupa.com/u/silverneo188)\
**Post date:** [October 1, 2012, 11:22am UTC](https://forum.kirupa.com/t/as2-percentage-based-random-choice/329679/1 "2012-10-01T11:22:01Z")

</div>

Ok so lets say I have a multi-dimension array with this data

[[“Attack 1”, 60], [“Attack 2”, 20], [“Attack 3”, 15], [“Attack 4”, 5] ]

ok so the first part of the 2nd dimension array is the label for an attack frame in a movieclip while the 2nd number is a percentage of that one being picked.

What would be a good formula for choosing one of those attacks based on their arrays?

Just to make it a little bit clearer, “Attack 1” for instance has a 60 just to stand for 60%, i need a formula that uses that 60 to form said percentage
