actionscript 3 - Data binding from a method in Flex -


I have the following mxml (some parts are omitted for shortened purpose):

  & Lt; Fx: script & gt; [Bindabile] Private var _dataSet: IDataSet; Public function set dataset (value: idataset) {_dataSet = value; } Private function getColorItem (itemName: *): string {if (itemName == "research") "# 31e5fc" return; ... and {trace ("unknown item:" + itemName); Return #ffffff; }} & Lt; / Fx: script & gt; & Lt; Spark: Rich Text color = "{this.getColorItem (this._dataSet.name)}" ... / ...  

Does anyone know why color is not being applied is? If I change the bond to the law, then for a continuous string (like # 31e5fc), does it work properly?

I need to change the color according to the data obtained by this component.

You have some strange things here First of all, you should return a UIT instead of your GetColorItem function string . Second, why not just call your dataset setter? Something like this:

  Public function set dataset (value: idataset) {_dataSet = value; MyRichText.setStyle ("Color", getColorItem (_dataSet.name);}  

Hope that helps.


Comments