Skip navigation
Currently Being Moderated

Initializer for 'color': cannot parse value of type uint from text 'colorUint'.

Mar 9, 2013 2:20 PM

What is wrong with my code? I get this error:

 

 

Initializer for 'color': cannot parse value of type uint from text 'colorUint'.

 

Code:

 

public static function convertStringToUint(value:String, mask:String):uint
   { 
    var colorString:String = "0x" + value; 
    var colorUint:uint = mx.core.Singleton.getInstance("mx.styles::IStyleManager2").getColorNa me( colorString ); 
   
    return colorUint; 
   }    


<s:Button id="Battery" x="10" y="44" width="60" height="30" label="Battery" fontSize="10" color="colorUint"/>
   

 
Replies
  • Currently Being Moderated
    Mar 9, 2013 8:41 PM   in reply to fsoender

    In color=”coloruint”, the compiler will see it as a string, not a variable.  To use a variable there, you have to use binding syntax {}

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 10, 2013 6:44 AM   in reply to fsoender

    -Data binding will not be able to detect assignments to "colorString".

     

    Means you need to add [Binding] to the variable.

    [Bindable]
    public var colorString:String; 
    

     

    The other issues is that a String is not a uint.  A uint is a numeric value.  So, after you create your String color value, you have to cast it as a uint.

     

     

    <s:Button id="Battery" x="10" y="44" width="60" height="30" label="Battery" fontSize="10" color="{new uint(colorString)}"/>
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points