Reputation: 7112
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!
Upvotes: 0
Views: 98
Reputation: 10325
What you're looking for is flex data binding.
In order to bind to a variable in MXML, try the following syntax.
<s:View ... title="{stringVar}" ... >
[Bindable] //metadata tag makes the variable bindable
public var stringVar:String = "StartingTitle";
Upvotes: 2
Reputation: 39408
Somewhere in ActionScript do this:
this.title = 'New Value'
So, let's say you had a TextInput, named myTitleText, like this:
There is an event handler for whenever the title changes. In the event handler, change the text:
protected function onChange():void{
this.title = myTitleText.text;
}
Upvotes: 0