Skip navigation
Currently Being Moderated

Problem with  uint

Mar 27, 2013 1:27 PM

I get an warning with this code, but I have the variable in binding already...

 

 

Warning: Data binding will not be able to detect assignments to "NewBatteryStatus"

 

 

 

 

 

[Bindable]

 

public var NewBatteryStatus:String;

 

 

 

 

          switch(NewBatteryStatus)

          {

          case 1:                                                                                                                

          NewBatteryStatus = "Red";                                                                                         

          break;

 

          case 2:                                                                                                                

          NewBatteryStatus = "Green";

          break;

 

          default:                                                                                                                

          NewBatteryStatus = "Yellow";                                                                                                   

          break;                  

          }                                             

 

 

<s:Button id="Battery" x="791" y="513" width="124" height="46" label="Battery" fontSize="20" color= "{new uint(NewBatteryStatus)}"/>

 
Replies
  • Currently Being Moderated
    Mar 28, 2013 2:03 AM   in reply to fsoender

    You cannot bind styles.

     

    Ask yourself  these questions:

     

    Is NewBatteryStatus a) a string, or b)a numerical type and why am I trying to use it as both?

     

    Why am I trying to set what is expected to be a string value to be a uint?

     

    Why do I continue to ignore the camel-case convention for variables, starting my variable names with a lower case letter and class names with a capital, thereby writing code that will tend to confuse from the very start.

     

    If binding was working, why is my variable name described as New, when really it's just the current battery status? the variable name should be something like batteryStatus or currentBatteryStatus but not newBatteryStatus.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 28, 2013 8:59 AM   in reply to fsoender

    Binding doesn't work with styles.  Maybe some else can say exactly why, but styles aren't quite the same as normal attributes and I don't think the bind mechanism can work with anything but straightforward attributes. Styles have to be set explicitly.

     

    Look styles up.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 28, 2013 10:28 AM   in reply to pauland

    Just change this...

     

    "{(batteryStatus)}"

     

    to this...

     

    "{batteryStatus}"

     

    and add [Bindable] to the var declaration.

     

     

    This should work.

     

    [Bindable] public var batteryStatus:String;


    BatteryStatus = "Red";


    <s:Button id="Battery" x="795" y="514" width="124" height="46" label="Battery" fontSize="20" color= "{batteryStatus}"/>

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 1, 2013 6:09 AM   in reply to fsoender

    You can't set it with binding. Set the style explicitly in code.

     

    battery.setStyle('color', 'red');

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 1, 2013 8:46 AM   in reply to fsoender

    Please ignore this; it's just a test.

     
    |
    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