A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: how to change the color for combobox values based on condition

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jun 2009
    Posts
    101

    Thumbs up how to change the color for combobox values based on condition

    hello friends,


    I need a small help from you guys. I am doing a simple combobox example. Now my requirement was, i want to differentiate the combobox values with some colors. I dont know how to do this. can you guys pls help me out on this. Suppose for ex: if my combobox data value exceeds 200 i want to display the items in "red" else i want to display in "green". i need solutions for this requirment.


    your help would be appreciated. i need it asap.


    -------------------------

    <?xml version="1.0" encoding="utf-8"?>
    <!-- Simple example to demonstrate the Halo ComboBox control. -->
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.events.DropdownEvent;

    [Bindable]
    public var cards:ArrayCollection = new ArrayCollection(
    [ {label:"Value1", data:100},
    {label:"Value2", data:200},
    {label:"Value3", data:300},
    {label:"Value4", data:400},
    {label:"Value5", data:500}]);

    private function closeHandler(evtropdownEvent):void {
    myLabel.text = "You selected: " + ComboBox(evt.target).selectedItem.label;
    myData.text = "Data: " + ComboBox(evt.target).selectedItem.data;
    }
    ]]>
    </fx:Script>

    <s:Panel title="Halo ComboBox Control Example"
    width="75%" height="75%"
    horizontalCenter="0" verticalCenter="0">
    <s:HGroup left="10" right="10" top="10" bottom="10">
    <mx:ComboBox dataProvider="{cards}" width="150"
    close="closeHandler(event);"/>

    <s:VGroup width="250">
    <s:Label width="200" color="blue" text="Select a type of credit card."/>
    <s:Label id="myLabel" text="You selected:"/>
    <s:Label id="myData" text="Data:"/>
    </s:VGroup>
    </s:HGroup>
    </s:Panel>

    </s:Application>


    --------------

    waiting for your replies.

    Rajesh

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Do you mean the text in the combobox or in the label component, which displays the value?
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member
    Join Date
    Jun 2009
    Posts
    101

    Thumbs up

    Hey thanks for your reply.

    I want to change the color of the text which is displaying inside comboBox, ie Value1 - green color
    Value2 - green color
    Value3 - Red color
    Value4 - Red color
    Value5 - Red color

    Ideally i want to differentiate the item's with color's based on a condition. this is what i am looking for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center