Hi guys,
I'm new to Flex programming.. and I need to do some iteration.
How do I perform loops in Flex?
And does Flex has "switch case"?
Thanks guys
Hi guys,
I'm new to Flex programming.. and I need to do some iteration.
How do I perform loops in Flex?
And does Flex has "switch case"?
Thanks guys
For Loops in Flex implemented as follows:
var i:int;
for (i = 0; i < 5; i++)
{
trace(i);
}
You can also do for each loops as :
var myArray:Array = ["name1", "name2", "name3"];
for each (var item in myArray)
{
}
While Loops:
var i:int = 0;
while (i < 10)
{
i++;
}
also Yes Flex does support switch statements these can be implemented as follows
var someDate:Date = new Date();
var dayNum:uint = someDate.getDay();
switch(dayNum)
{
case 0:
trace("Sunday");
break;
case 1:
trace("Monday");
break;
case 2:
trace("Tuesday");
break;
case 3:
trace("Wednesday");
break;
case 4:
trace("Thursday");
break;
case 5:
trace("Friday");
break;
case 6:
trace("Saturday");
break;
default:
trace("Out of range");
break;
}
remember when writing this funcionality in flex it has to be contained within the script tags**