#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    57
    Rep Power
    11

    List Component Text Color RollOver


    Ahhhhrrrrg!!!!!

    For the life of me i cannot figure this out or cannot find simple straight forward documentation.

    Previously in AS2, to set the style for a List Component when the mouse was over an item you would simple set it with
    Code:
    setStyle("rollOverColor", 0x000000);
    I've been trying to find info on how the heck you do this in AS3, cause the above dont work.

    i've been playing with the following code, but it does not have a rollOver property
    Code:
    var tf:TextFormat = new TextFormat();
    tf.color = 0x00FF00;
    tf.font = "Andale Mono";
    tf.size = 14;
    So please help, does anyone have a clue?

    PS, normally when a programing language is changed, is is done at an easing speed, but AHHH! NO!!! not with AS3, it has changed 101%

    Sorry just letting some frustration out.

    Thanks for the help.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    1
    Rep Power
    0
    Hummmm, I've just spend 3 hours trying to figure it out myself. I've found a way to crack it below but it's not as simple as it used to be in AS2 ;( If you extent the CellRender Class with a custom one you can also prob achieve the same result... hope it helps. let me know if you find a simpler solution...

    Code:
    import fl.events.*;
    import fl.managers.*;
    import fl.controls.*;
    import fl.controls.listClasses.*;
    
    stop();
    
    var Arial_11_grey = new TextFormat();
    Arial_11_grey.font = "Arial";
    Arial_11_grey.color = 0xcccccc;
    Arial_11_grey.size = 11;
    StyleManager.setStyle("Arial_11_grey",Arial_11_grey);
    
    var Arial_11_red = new TextFormat();
    Arial_11_red.font = "Arial";
    Arial_11_red.color = 0xff0000;
    Arial_11_red.size = 11;
    StyleManager.setStyle("Arial_11_red",Arial_11_red);
    
    StyleManager.setComponentStyle(ComboBox,"textFormat",StyleManager.getStyle("Arial_11_grey"));
    StyleManager.setComponentStyle(TextInput,"textFormat",StyleManager.getStyle("Arial_11_grey")); // comboBox labelField
    StyleManager.setComponentStyle(CellRenderer,"textFormat",StyleManager.getStyle("Arial_11_grey"));
    
    var myComboBox:ComboBox = new ComboBox();
    myComboBox.addItem({label:"Item 1", price:0.34});
    myComboBox.addItem({label:"Item 2", price:13.19});
    myComboBox.addItem({label:"item 3", price:2.96});
    myComboBox.addItem({label:"Item 4", price:3.49});
    myComboBox.addItem({label:"Item 5", price:1.27});
    myComboBox.move(10, 10);
    
    addChild(myComboBox);
    
    myComboBox.dropdown.addEventListener(ListEvent.ITEM_ROLL_OVER, rollOverListener);
    myComboBox.dropdown.addEventListener(ListEvent.ITEM_ROLL_OUT, rollOutListener);
    
    function rollOverListener(e:ListEvent)
    {
    	var cr:CellRenderer = e.target.itemToCellRenderer(e.item) as CellRenderer;
    	cr.setStyle("textFormat",StyleManager.getStyle("Arial_11_red"));
    }
    
    function rollOutListener(e:ListEvent)
    {
    	var cr:CellRenderer = e.target.itemToCellRenderer(e.item) as CellRenderer;
    	cr.setStyle("textFormat",StyleManager.getStyle("Arial_11_grey"));
    }
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Did this work?


    for NOOBs who use this code:
    BE SURE that when you use the BEAUTIFUL CODE THAT WORKS LIKE A CHARM...to drag an instance of a combobox on to the stage BEFORE you test...delete it, then try to test...it works...WOO HOO.
    You have NO IDEA how grateful I am to this poster...there is a god and you, my friend, are a messenger from him/her/it/them!!!!

    Been a few years since this was posted, but I copied the text into a new file and it threw errors:
    1046: Type was not found or was not a compile-time constant: ListEvent.
    ON: function rollOverListener(e:ListEvent)
    and on:
    function rollOutListener(e:ListEvent)

    I agree whole-heartedly with the original poster...AS3 is MUCH more difficult to write. What took 1 line now takes a major project.

    Thanks for any guidance...all I really need to do is change the rollover colour...god help me.

    Thanks :-)
    Last edited by ChicagoMan2007; December 1st, 2011 at 11:03 AM. Reason: I'm an idiot

IMN logo majestic logo threadwatch logo seochat tools logo