vendredi 24 février 2017

Understanding Actionscript 3 Code

I was given this piece of code and am trying to understand it as best as I can. I have ran the code and understand what it does, but there are a few lines which I do not know how to explain.

Code here

Here is what I have come up with so far:

In line 1 of the code shown, we have created a new Array called “theElements”. It contains 5 different elements named “Earth, Wind, Fire, Water & Ether.”

In line 2 of the code, we are creating a variable with a String function, however this line of code seems to be an error that was left in to the code as “element” does not feature within our code again. This line of code was used in a previous example and had been forgotten to be removed. We can successfully run the piece of code without any errors if we remove this line.

In line 3 of the code, we create a variable called “numberOfRoles” and give this a 10 value.

In line 5 of the code, we pull the Array “theElements” and variable “numberOfRoles” and use them as attributes, while naming them both as “roleThem”

In line 7 of the code, we create a function and use roleThem

In line 9 we use the while loop, which will repeat as long as the statement “numberOfRoles > 0” is true.

In line 12 we check that our variable “numberOfRoles” is always equal.

I am stuck on explaining Line 10/11 and 16-19. I know that lines 16-19 pick 10 of the elements at random and display then which you can see, however I do not know how to explain it in the correct manner. I am still learning the basics of Actionscript so any help would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire