开发者

In flex4 & as3 how do you change the button label dynamically?

开发者 https://www.devze.com 2023-04-10 18:04 出处:网络
Is there any way to change Spark button label dynamically? When i click on it开发者_C百科, i want the label to change. I bind the String to label and gives value for the first time, but even flashBuil

Is there any way to change Spark button label dynamically? When i click on it开发者_C百科, i want the label to change. I bind the String to label and gives value for the first time, but even flashBuilder shows me that Data binding will not be able to detect assignments. Here is my button:

<s:Button name="button" label="{butt}" x="5" y="3" useHandCursor="true" 
          click="start()" buttonMode="true" cornerRadius="5" 
          skinClass="skins.CustomButtom"/>

And here is assigment:

public var butt:String = "Start";

Update Both answers work.


Make the variable Bindable like this:

[Bindable]  
public var butt:String = "Start";


It is not advisable to have buttons with changing labels.
Even if you must, it is preferable to change the label property directly instead of introducing a binding because Flash Player needs to instantiate extra listeners for bound variables.
In this case, a binding is required only if you are going to be changing the label frequently.

Without the bindable, you might have noticed that Flash will assign the value "Start" to the label of the button (generally, the value of the bound variable at the time of creation of the button).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号