actionscript 3 - AS3 day of week shuffle -


having issues in code. trying shuffle days of week in 4 dynamic text boxes if today thursday other box shows friday , other after shows saturday, sunday... , days shuffle when comes sunday code shows null instead day name, did go wrong? here code:

var dayofweek_array:array = new array("sunday", "monday", "tuesday", "wensday", "thursday", "friday", "saturday"); var today_date:date = new date(); var day_str:string = dayofweek_array[today_date.getday()+0]; var day_str1:string = dayofweek_array[today_date.getday()+1]; var day_str2:string = dayofweek_array[today_date.getday()+2];   var tmp1 = today_date.getday() + 3; if(tmp1 > 6) tmp -= 7; var day_str3:string = dayofweek_array[tmp];  var tmp = today_date.getday() + 4; if(tmp > 6) tmp -= 7; var day_str4:string = dayofweek_array[tmp];  mytextfield1.text = (""+day_str1); mytextfield2.text = (""+day_str2); mytextfield3.text = (""+day_str3); mytextfield4.text = (""+day_str4); 

i point modulo operator: % http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/operators.html#modulo

using can dayofweek_array[(today_date.getday()+0) % 7];

this return number between 0 , 6, so, won't nulls in text fields

different story is, put textfields in array, can manage them using cycles. that, can change behaviour or number of fields in future.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -