Im making a random drop item system.
I was thinking of making a array like this:
var Items:Array = ["HP","ST","SWORD"]
then...
if(Items == SWORD){
//drop sword
//do code here
}
but i have no idea of how to access and use 1 value from an array.
I think i need to use something like math.floor or math.random but i dont know how to go foward with this.
Thanks in advance.
I don't know AS 1 or AS 2 but usually generally speaking array items are accessed with square brackets:
myArray=[item1, item2, item3]
myArray[0]=item1
myArray[1]=item2
myArray[2]=item3
when I say = I mean that it represents that array item not that that is the syntax for the code.
Message was edited by: markerline
There should be a random attribute of the Math class. Again I don't know AS 1 or AS 2 but in AS 3 that would be something like Math.random() . There should be plenty of examples online or even in the AS 2 Reference Guide on adobe's website.
You would assign a variable to take the integer value output by the random function and place that within your array's brackets. That's the theory anyway. I'll see if I can find something for you but have a search in the meantime.
Have a look at this document to get you started:
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=000012 20.html
North America
Europe, Middle East and Africa
Asia Pacific