In a class, like so: public static var ITEM_COLORS:Array = [0xFF0000, 0x00FF00, 0x0000FF, 0xFFFFFF]; // (or whichever colors) // assuming property "countItem" is the number of items // and the method "getItem" retrieves an item with a "color" property private function colorItems():Void { for (var i:Number = 0; i < countItem; ++i) { getItem(i).color = ITEM_COLORS[i % ITEM_COLORS.length]; } }
Note that in this scheme the index number starts at 0, not 1. That's a better practice in general. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sajid Saiyed Sent: Thursday, June 22, 2006 10:54 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Alternate row color (Modulo Operator) Hi, I have a question about using Modulo Operator. I can easily do an Odd / Even using i%2 !=0 Where i can be any supllied number. My question is, I have a list of movieclips (arranged one below another). I want to use 4 different colours to differentiate them. So, list items 1, 5, 9, ... will have Color-1. items 2, 6, 10, ... will have another Color-2. items 3, 7, 11, ... will have third Colou-3. items 4, 8, 12, ... will have fourth Color-4. And so on.... Can someone point me to the right direction as to how I should use the moludo? Wether modulo operator is the right way to do this? Thanks _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com