[Flashcoders] Alternate row color (Modulo Operator)

2006-06-22 Thread Sajid Saiyed

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


RE: [Flashcoders] Alternate row color (Modulo Operator)

2006-06-22 Thread André Goliath
You are in modulo 4 here: 4 Categories - 0, 1, 2, or 3 as possible modulo
results 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sajid Saiyed
Sent: Thursday, June 22, 2006 7:54 PM
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


Re: [Flashcoders] Alternate row color (Modulo Operator)

2006-06-22 Thread Sajid Saiyed

Perfect, Mike this worked.

Thanks a lot.

On 6/23/06, Mike [EMAIL PROTECTED] wrote:

In a class, like so:

public static var ITEM_COLORS:Array = [0xFF, 0x00FF00, 0xFF,
0xFF]; // (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


___
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