I have 7 Canvases, one for each day of the week. When the user wants
to add something to the weekly schedule, it could have multiple days
(Monday and Wednesday, for example). The days to add are in a string
like this: "UMTWRFS", where each letter represents a corresponding day
of the week. If the days are just Monday, Wednesday, and Friday, the
string would look like this: "MWF".
Here's my problem, I wrote ActionScript to check if a day is in the
string and if so, add it to its corresponding canvas via addChild().
Here is my code:
if (days.search("M")!=-1){
mon.addChild(item);
}
if (days.search("T")!=-1){
tues.addChild(item);
}
if (days.search("W")!=-1){
wed.addChild(item);
}
if (days.search("R")!=-1){
thurs.addChild(item);
}
if (days.search("F")!=-1){
fri.addChild(item);
}
if (days.search("S")!=-1){
sat.addChild(item);
}
if (days.search("U")!=-1){
sun.addChild(item);
}
My problem is that if "days" is multiple days, only the last day is
added to its canvas. This is very strange since I am using 7
independent "if" statements. I debugged and I saw the code execute
correctly for all of the days in the string, but only the last one
showed up visually in the canvas. Am I doing something wrong? Any help
is appreciated.