0

This seems like it should be super easy, but I can't figure it out. How do you dynamically change the title of a page based on some variable?

By title, I mean the title of my view like this:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" title="DynamicTitle" creationComplete="init(event)">

Thanks!

4

2 回答 2

2

您正在寻找的是弹性数据绑定。

为了绑定到 MXML 中的变量,请尝试以下语法。

<s:View ... title="{stringVar}" ... >

[Bindable] //metadata tag makes the variable bindable
public var stringVar:String = "StartingTitle";
于 2012-05-04T18:04:16.043 回答
0

在 ActionScript 中的某个地方执行此操作:

this.title = 'New Value'

因此,假设您有一个名为 myTitleText 的 TextInput,如下所示:

每当标题更改时,都会有一个事件处理程序。在事件处理程序中,更改文本:

protected function onChange():void{
 this.title = myTitleText.text;
}
于 2012-05-04T18:04:02.263 回答