actionscript 3 - categorize arrays AS3 -


i've got array :

var usersarray:array = new array("this array1 , it's array","this array2", "this array3", "this array4", "this array"); usersarray.push(usersarray.splice(usersarray.indexof("userid"), 1));  var companion:string = usersarray[math.floor(math.random() * (usersarray.length - 1))];    trace(companion); 

is possible class array letter or number array long ?

like

if (companion==a){ trace("this array 1") } 

instead of

if (companion=="this array1 , it's array"){ trace("this array 1") } 

thanks !

if understand question well,you can set variable strings in array:

var usersarray:array = new array("this array1 , it's array","this array2", "this array3", "this array4", "this array"); usersarray.push(usersarray.splice(usersarray.indexof("userid"), 1)); var a:string=userarray[0]; var b:string=userarray[1]; var c:string=userarray[2]; var d:string=userarray[3]; var e:string=userarray[4];    var companion:string = usersarray[math.floor(math.random() * (usersarray.length - 1))];    trace(companion);     if (companion==a){   trace("this array 1") } 

or can write:

 if(companion==userarray[0]){   trace("this array 1") } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -