Changing Label text color based on some conditions

Hi,
I have these labels and I would like to change the text color IF the text has some specific value (coming from an XML created by a program); for example the default text color is red, but if the text value is "Yes", the text color should be green.
Any helps much appreciatted, as usual...
Thanks.

unsure, but you might be able to get away with something like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            public function changeColor(value:String):uint
                if(value == "Yes")
                    return 0x007F00;
                else
                    return 0x7F0000;
        ]]>
    </mx:Script>
    <mx:Panel x="343" y="199" width="250" height="200" layout="absolute">
        <mx:Label id="lbl1" text="Yes" color="{changeColor(lbl1.text)}" x="102.5" y="10"/>
        <mx:Label id="lbl2" text="BlahhhhhBlahhhh" color="{changeColor(lbl2.text)}" x="97" y="36"/>
        <mx:Label id="lbl3" text="Exampleeeeeeee"  color="{changeColor(lbl3.text)}" x="97" y="62"/>
    </mx:Panel>
</mx:Application>
using a single label in an item renderer, passing across the 'data.text' value

Similar Messages

  • Change X, Y position of a text frame based on some conditions

    Hi All,
    I am trying to re-position the Y position alone of all text frames in a documennt if that text frame has certain Y position. Here is the code I tried.
    It works, but, it place all the text frames in to the given myTextFrame.move ( ["216.425 pt","54 pt"] ); one on another. Whereas, I need to change Y position of only the text frames with the following conditions.
    The conditions are:
    If X="216.425 pt" AND Y="103.89 pt", change to X="216.425 pt" and Y="54 pt"   OR
    If X="216.425 pt" AND Y="78.945 pt", change to X="216.425 pt" and Y="54 pt"    OR
    If X="216.425 pt" AND Y="79.157 pt", change to X="216.425 pt" and Y="54 pt"    OR
    If X="213.425 pt" AND Y="486.647 pt", change to X="216.425 pt" and Y="54 pt"    OR
    If X="213.425 pt" AND Y="74.409 pt", change to X="216.425 pt" and Y="54 pt"   
    Please help me on this to add the above conditions into the following code and reposition only the text frames has the above said XY positions.  Is there anyother way other than "move" statement?
    var myDocument=app.activeDocument;
    var myPages=myDocument.pages;
        for(p=0;p<myPages.length;p++) {
        var allTextFrames=myPages[p].textFrames;
            for (s=0; s<allTextFrames.length; s++) {
                        var myTextFrame = allTextFrames[s];
                        var myTextFrameBounds =  myTextFrame.geometricBounds;
                        var properly_aligned = "54 pt";
                            if ((myTextFrameBounds[0] = "103.89 pt") && (myTextFrameBounds[1] ="216.425 pt")) {
                                myTextFrame.move ( ["216.425 pt","54 pt"] );

    Hi Jongware,
    Thanks for your reply.
    I have modified the code little bit after referring one of the post. Here is the updated code. It is working fine for the whole number (var oldposition1) as input value and does not work for decimal values (var oldposition2, var oldposition3, var oldposition4 and var oldposition5). However, it repositions the frames with decimal values (newposition1, newposition2 and newposition3). I am facing problem with the decimal input values for original position of text frames. Is there any other way to give decimal values as input as my document comes with these decimal values as X, Y position.
    var oldposition1 = [216, 103] // original position, upper left corner
    var oldposition2 = [216.425, 78.945] // original position, upper left corner
    var oldposition3 = [216.425, 79.157] // original position, upper left corner
    var oldposition4 = [213.425, 74.409] // original position, upper left corner
    var oldposition5 = [213.425, 486.647] // original position, upper left corner
    var newposition1 = [216.425, 54] // new position, upper left corner
    var newposition2 = [36, 54] // new position, upper left corner
    var newposition3 = [216.425, 437.4] // new position, upper left corner
    var myObjects = app.activeDocument.pageItems.everyItem().getElements();
    for (var i=0; i<myObjects.length; i++){
        if (Math.round(myObjects[i].geometricBounds[1])==oldposition1[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition1[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition2[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition2[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition3[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition3[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition4[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition4[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition5[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition5[1]){
            myObjects[i].move(newposition3);

  • Change Icon Label Text Color

    So, I wanted to change the Finder Window background color to black. But when I do so, the text for the labels of the icons become un-readable. See picture.
    So I wanted to change the Label Text to white or some other lighter color. I'm surprised Mac OS X did not do it automatically. How do I change it?

    AFAIK, you can't. All I can suggest is use one of Apple's Desktop pictures and be done with it.

  • Display Image(which set as behind text)   based on some condition.

    hi all
    I have developed a xml report and in that rtf am displaying a static image (which is set as behin text).
    But i need to display the image based on some condition
    for example i have a field as ORG_ID
    if org_id=87 then image should display for that purpose am planning to use <?if:ORG_ID=87?> condition but where to place this condition for the image.
    kindly help me
    thanks for all in advance.

    that too not working because
    on image am displaying some other fields.
    see i think you didn't get my point.
    in my out put page am displaying item details ,quantity,and cost and customer details just like invoice copy .
    behind this data am displaying my company logo which will capture whole page size..
    if i place the image in table then fields will be automatically in table so i cant restrict image in this way.
    Kindly suggest any other way that works only for image which is behind text. i mean condition should be applicable only for image and leaving all other fileds in rtf.
    or
    help on this how to set a dynamic image as behind the text.
    Edited by: maddy on Nov 28, 2012 7:32 AM
    Edited by: maddy on Nov 28, 2012 7:35 AM

  • Changing field text color and fill based on input value.

    I am trying to create a field that can be red, yellow or green.  In the end, what I need is a box that can be made red, yellow or green by the form user.  My strategy is to use a validation script to change the field and text color based on the field input.  So if you type "red", the text and field turn red, essentially making a red box.  The field is named "GoalColor".
    Am I headed in the right direction to get make this dynamic colored box?
    This script works but you must type "red" into the field(including quotation marks).  Any ideas on why the word red alone isn't triggering it? 
    var vcolor = this.getField("GoalColor").value;
    if (vcolor == "red") {
        this.getField('GoalColor').fillColor = color.red;
    } else {
        this.getField('GoalColor').fillColor = color.white;
    I have also tried - works if you type 'red'
    var vcolor = this.getField("GoalColor").value;
    if (vcolor == 'red') {
        this.getField('GoalColor').fillColor = color.red;
    } else {
        this.getField('GoalColor').fillColor = color.white;
    and  - does not work
    var vcolor = this.getField("GoalColor").value;
    if ( vcolor == red ) {
        this.getField('GoalColor').fillColor = color.red;
    } else {
        this.getField('GoalColor').fillColor = color.white;
    Thanks!

    And you don't need to add the quotation marks in the text field. In fact, doing it will cause the script not to identify the word.

  • How to dynamically add/remove a button from the ribbon based on some condition? (Ribbon XML)

    Hi,
    I have a ribbon (done using ribbon XML) with menu options. I need to remove few buttons from the menu dynamically based on some condition. Also, I want to change the label of another button. How to achieve this programmatically? (C#)
    Thanks in advance.
    Thanks Prasad

    Hello Prasad,
    Use callbacks for populating Ribbon controls such as menu, dropDown, gallery and etc. Then you can use the
    Invalidate or
    InvalidateControl methods of the
    IRibbonUI interface to get your callbacks invoked when required. Thus, you will be able to delete the required item(s).
    You will find the following articles in MSDN helpful:
    Chapter 11: Creating Dynamic Ribbon Customizations (1 of 2)
    Chapter 11: Creating Dynamic Ribbon Customizations (2 of 2)
    To change the label of your controls at runtime you need to use the getLabel callback and call the Invalidate or InvalidateControl methods of the IRibbonUI interface. The following series of articles describe the Fluent UI in depth:
    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

  • Change MVThemeBasedFOI text color

    Hi to all,
    I'm using Oracle maps, the last version that i've downloaded.
    I've defined a layer:
    stradeLayer = new MVThemeBasedFOI('stradeLayer','DBTI.STRADE');
    stradeLayer.enableAutoWholeImage(true);
    stradeLayer.setVisible(false);
    stradeLayer.enableLabels(true);
    for this layer i use some style rules:
    <?xml version="1.0" standalone="yes"?>
    <styling_rules>
    <rule column="DUG,NOME">
    <features style="L.RULE LIGHT 96">
    SELECT TP03_GEOMETRIA,
    D.TP17_DESCRIZIONE as DUG,
    T.TP07_NOME AS NOME,...
    </features>
    <label column="VIA_NOME" style="T.SHIELD2"> 1 </label>
    </rule>
    </styling_rules>
    is it possibile to change temporarily text color or font,
    could you suggest something?
    Thank in advace,
    Francesco

    Add the following style rule to your document
    ul.MenuBarHorizontal ul a {
        color: red;
    changing the colour to suit.

  • Changing hyperlink text colors.

    I saw few posts asking about changing hyperlink text colors. And there are many camps regarding this topic. Suzanne Boben would recommend editing template XML . Some would recommend editing published HTML code. Some would recommend editing CSS code.
    But it came down to couple things.
    1) proficient in XML, HTML or CSS
    2) tried different colors, but it did turned out as expected
    One easy way is editing CSS files, this only apply to pages' hyperlink text; if your text got turn to PNGs, read no further .
    iWeb generates a CSS file for the associated HTML page - CSS file is in the Page_files folder.
    Edit the CSS files and keep copies of them, then you won't have to edit them again the next time you publish you sites.
    These CSS files are quite easy to understand, all you have to do is to look for a { , a:visited { and a:hover { .
    They contain RGB (Red Green Blue) values for link color, visited link color and rollover color.
    But what about those #8000FF and #4c4c4c?
    Well, I know they are RGB hexadecimal color values, but I don't what colors they are, so I came up with Argiope (Argiope is a family colorful spiders).
    It's a colors picker application to help with choosing background color, link color and rollover color. It'll give you the exact RGB hexadecimal value of chosen color.
    You can find Argiope here. Enjoy

    It can be done, but I have to do too much works.
    I already have a a script to do that, but it's quite complicated for an average bear.
    http://www.geocities.com/[email protected]/iWeb_utils --> LinksColors.zip
    Does just that, it is flexible, you can configure the colors for individual page, but it is quite different to configure. Look at the colors.txt and page.txt.
    If you really want to know more, ping me.

  • Possible to change review text color and wording

    I've searched high and wide to try changing the text color for the review mode field "CORRECT ANSWERS" that shows on a fill in the blank/ short answer question. Ideally I'd like white text (it's set at black) and I'd like to have it say "Correct answer(s)" or even somethinge else. I don't like the all caps that's used either.
    I've looked at the Object Style Manager but I don't see this particular field available/editable. Has anyone found where in the c:\Program Files\Adobe... files this setting is controlled - a .dll, .xml, .txt? I don't mind changing it to white there if I have to.

    Hi, thanks. Cap 7. I whipped up that course from scratch, no particular theme applied. Also to answer your question, I looked at the master slide and that particular review mode field isn't present, just the initial objects like the text input field.It's frustrating how everything but the CORRECT ANSWERS label is editable via the Object Style Manager. Why they forgot to include it is beyond me. I'm left at using "Hack a Cap" methodology by looking at all the .dll, txt. xml files hoping to fix it there because as far as I know you can't just turn the CORRECT ANSWERS field off even if you wanted to. Unfortunately almost all of our screenshots in our courses will have a royal blue background.

  • Calling a window in sapscript based on some conditions

    Hi all,
    I want to call a window in SAPScript based on some conditions.Plz suggest how could i do that.
    Regards,
    Chinmay.

    Hi,
    Use a text element in that window.
    ie..
    /E  TEXT
    &VBAK-VBELN&
    in ur driver program
    if vbak-vbeln is not initial. ( your condition)
    call function 'write_form'
    element = 'TEXT'
    window = 'WINDOW_NAME'
    Endif.
    hope this helps
    santhosh

  • I not read label text color

    Dear Support,
    I am legally-blind and deaf, I bought ipad3 last month, I setup enabled White & Black and Triple-click is Black/White, I make and save solid black.jpg and solid white.jpg in ipad3, click wallpaper done...  start Lock  see black (good) then home, i see icon with white text and black background, good,  I click setting, mail, message are white background, I can't read I press triple-click switch black, I see it when finish press Home back white background, I press triple-click back black, I am not happy lot of triple-click, I am worries button will be broke soon.. but I got idea change white.jpg,  switch to black background, i press lock good, then home is bad, black background is ok but I not read white text on icon, it is blank, I press seeting, mail, message are good   no need triple-click  but I need how fix change color on label text label ?
    I search website I type "change label text icon", I saw many had it but it is jailbreak, I don't want it, because void of warranty
    any fix label text icon?
    help me?
    Thank out
    Richard

    I am pretty sure that I understand what you are trying to do, but I do not know of any way that you can change the color of the text on the app icons. Your only options are black on white - or the standard white text labels.
    As you have discovered, there is no way to change how the iOS works without modification of the device and you know that voids the warranty and it could cause even more problems down the road.
    I'm sorry, but I think that you will have to take a chance on the triple clicks. The iPad does come with a one year warranty and Apple has built the Accessibility feature into the iPad knowing that the triple click will be used by people such as yourself. I would not hesitate to use the feature.

  • How do I change the text color of footers on select pages? (InDesign CS6)

    Good afternoon,
    Months ago, I worked with a graphic designer to put together a 100-page workbook for my training company. He turned all of the files over to me and I'd like to make a small change before we print another run for a new client. Specifically, I'm having trouble changing the text color on select pages. Since a picture says 1,000 words, let me give you an example:
    As you can see, the copyright information on the right side of the page is difficult to read here when placed over the photo (you may have to look closely, but it's along the guy's sleeve). What I'd love to do is change that part of the footer (not the left, page number side) to white text. This would make it quite a bit easier to read. There's a number of other pages in the book that I want to make this change to. I'm not sure why I never noticed it or mentioned it to the designer. I suppose I've become more discerning since then.
    Let me tell you what I've tried to do:
    I learned how to override master pages by CTRL+SHIFT clicking on the footer. However, this has not worked for me. It allows me to change the page number part, but not the copyright side. Additionally, sometimes when I override the master the formatting of the footer goes goofy. For instance, the left side and right side come together and end up in the middle of the page I'm working on.
    I'm looking for a quick way to go through and make the footers easier to read on pages where they are backed by a photo. Hoping you can help me. Please let me know if you need any other information.
    Best,
    Taylor

    I think you should have left it as it was. It seems like what you had was single pages flowing as spreads within InDesign. Like below. That is the correct way, and when you changed it to all single, it did create your footer problems.
    Will you be sending the file as a PDF to your online printer? If so, then leaving the InDesign file set as below is fine. The PDF output will separate the pages.
    All you have to do is make sure that Pages, not Spreads, is chosen when you output the PDF

  • How do i change the text color in ichat?

    How do i change the text color in ichat?

    Hi,
    In One Chat by word or letter go to the Format Menu as you type (Highlight and change like you would in any other App)
    On a more permanent basis the Font, it's colour and the IM background colour are set in iChat Menu > Preferences > Messages
    10:12 PM      Wednesday; November 23, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How do I change the text color from blue in Safari on Macbook Pro?

    I have trouble seeing the light blue text color -- many article use this.  How can I change the text color?

    Is this a particular website where you see the light blue color?
    If so, please post a link to that site in your Reply.
    Exactly which light blue color are you referrting to ??

  • How do I change the text color in a call out box?

    How do I change the text color in a call out box?

    See http://help.adobe.com/en_US/acrobat/X/standard/using/WS58a04a822e3e50102bd615109794195ff-7 e5a.w.html
    Also http://helpx.adobe.com/acrobat/kb/unable-edit-properties-text-box.html

Maybe you are looking for

  • Issue at Delivery

    Good day everyone, We have performed customization at SD Devliery, inserted few screen at VL01n/02n/03n tcodes. Customization done to convert the delivered quantity using a conversion formula and then overwrite the delivered quanitty. For example: de

  • TS1398 what the **** is wrong with i pad wifi?????????

    Why won't i pad connect to wifi????

  • Cancellation of backflushing in plant maintenance module

    Hi all, Can we stop the backflushing in plant maintenance module? i have not activated backflushing in the material and also in the work center. Still, when i give the materials in the order while confirming it, the materials are issued from the stor

  • Itunes music purchase re-download

    My music library got erased and trying to re-download a music album i bought previously. Only one song from the album appears in my itunes "Purchased" list. Any way to get the whole album to appear in my purchased list or re-download? Thanks!

  • Why after updating to iOS 5 does my application functions start up slower than before updating?

    Why does my iPhone 3 seem to have slower reaction time ( starting up applications i.e. receiving and sending of sms , games apps etc) after updating to iSO 5?? Is there a update soon to correct this issue?? Friends also experience the same issue.