3 Replies Latest reply on May 24, 2007 2:18 AM by marxan69

    Change the title window on a special event

    marxan69
      Hi everybody,

      I'm a new user in Flex so, sorry if my question seems too easy!
      __________________________________________________

      <mx:TitleWindow width="470" height="600" closeButton="true" title="Create a new expert" horizontalAlign="center"

      I'd like to change the window title because this page is used in 2 different cases, one is to create a new expert and the other one to modify it. All of the informations are identical in these 2 pages expect the title which should be: modifify expert in the other case.

      My idea is to put a global variable that will contain a string:" Create new expert". I'm doing a test to know if the expert already exists and if he does, I will change the value of my string: "modify expert".

      is that code will be possible to do?

      <mx:TitleWindow width="470" height="600" closeButton="true" title=MYVARIABLE horizontalAlign="center"

      Could you show me the syntax to use to make this change.

      Thanks in advance!

      Anthony
        • 1. Re: Change the title window on a special event
          neil manuell
          [Bindable]
          var myVar:String="hello"

          <mx:TitleWindow id="myTitleWindow" width="470" height="600" closeButton="true" title="{myVar}" horizontalAlign="center"

          that will change the title only at the creation of the component
          add a binding tag:

          <mx:Binding source="myVar" destination="myTitleWindow.title"/>

          or you can bind to a getter setter:


          var myVar:String="hello"

          [Bindable]
          public function set changeTitle(txt:String):void{
          myVar = txt
          }
          public function get changeTitle():String{
          return myVar
          }


          <mx:TitleWindow id="myTitleWindow" width="470" height="600" closeButton="true" title="{changeTitle}" horizontalAlign="center"
          <mx:Binding source="changeTitle" destination="myTitleWindow.title"/>

          • 2. Re: Change the title window on a special event
            neil manuell Level 1
            sorry I sound be more explicit - in that I havn't included Script tag

            <mx:Script>
            <![CDATA[
            [Bindable]
            public function set changeTitle(txt:String):void{
            myVar = txt
            }
            public function get changeTitle():String{
            return myVar
            }
            ]]>
            </mx:Script>

            <mx:TitleWindow id="myTitleWindow" width="470" height="600" closeButton="true" title="{changeTitle}" horizontalAlign="center"
            <mx:Binding source="changeTitle" destination="myTitleWindow.title"/>
            • 3. Re: Change the title window on a special event
              marxan69 Level 1
              Thanks for your help,

              How can I use the setter to change the content of the MyVar?

              By default the value should be "create the expert". Then if the user click on the button modify, the title should change: "modifiy the expert". But then if the user click on the button: create, the title will be "create the expert".

              It's not my code I try to modify, so I guess I should use this function to use the setter:

              private function checkExpertExists() : Void {
              if (expertId != undefined) return;
              var windowObject = this;
              var myExpertService:mx.remoting.NetServiceProxy;

              var responseHandler = {};
              responseHandler.onResult = function(results:Object):Void {
              var result:String = String(results);
              if ('true' == result) Alert.show('Mutiple experts found with this registration ID!', 'Warning');
              else if ('false' == result) {}
              else {
              Alert.show('An expert with this registration ID exists: ' + results.firstname + ' ' + results.lastname, 'Warning');
              }

              I hope this is clear and that you'll be able to help.

              Thanks a lot