3 Replies Latest reply on Nov 8, 2010 4:28 PM by the0reticalyield

    ...\n character not working any advice?

    the0reticalyield

      hello, so we are in the process of creating an RIA for my software engineering class and i have a help method that when clicked displays a pop up box with the instructions for the page, in the early iterations of the project the new line character worked fine and would make a new line so i could display the text cleanly...now as we have progressed into the project and added more modules the new line character is not working nor is \r\n …whenever i use \n or \r\n it just deletes the text after \n whereas before it would work and make a new line…below is the code for the help method…any advice would be greatly appreciated as i ve had to just change the dimensions of the pop up box to allow it to display the text i don't like this as there is not a cohesive feel from page to page…HELP!

       

       

       

      //pop up box function:

      import mx.events.CloseEvent;

      import mx.containers.TitleWindow;

      import mx.managers.PopUpManager;

      private function launchPopUp():void

      {

      var titleWindow:TitleWindow = new TitleWindow();

      var label:Label = new Label();

       

      label.text = "Click on the sound icon to hear the name of a leg part. " +

      "Then, click on the part that it names. If you are correct, the part will stay highlighted. \r\n" +

      "If you would like to practice more, go back to try.";

       

      titleWindow.addChild(label);

       

      titleWindow.width = 1050;

      titleWindow.height = 125;

      titleWindow.title = "HELP";

      titleWindow.addChild(label);

       

      titleWindow.showCloseButton = true;

      titleWindow.addEventListener(CloseEvent.CLOSE, closeClicked);

      PopUpManager.addPopUp(titleWindow, this);

      PopUpManager.centerPopUp(titleWindow);

      }

       

      private function closeClicked(event:CloseEvent):void

      {

      var titleWindow:TitleWindow = event.currentTarget as TitleWindow;

      PopUpManager.removePopUp(titleWindow);

      }

       

      so for example when this code is complied and run the text that is displayed is "Click on the sound icon to hear the name of a leg part.  Then, click on the part that it names.  If you are correct, the part will stay highlighted."

       

      it doesn't display the line of text after the \n character….help/advice on this would be immensely appreciated!!!  Thank you in advance!

        • 1. Re: ...\n character not working any advice?
          Flex harUI Adobe Employee

          Mx.controls.Label is single-line only.  Try mx.controls.Text

          • 2. Re: ...\n character not working any advice?
            the0reticalyield Level 1

            Thanks!!! Mystery solved!!! lol

            • 3. Re: ...\n character not working any advice?
              the0reticalyield Level 1

              here is the solution i can up with RE: \n issue…kinda new to flash builder and flex so feedback would be greatly appreciated!!!!

               

               

              //pop up box function:

              import mx.events.CloseEvent;

              import mx.containers.TitleWindow;

              import mx.managers.PopUpManager;

              import mx.controls.Text;

              private function launchPopUp():void  //launches help pop up box when help icon is clicked

              {

              var titleWindow:TitleWindow = new TitleWindow();

              var label:Text = new Text();

               

               

              //the text goes here: new line character is now again operational

              label.text = "Click on the sound icon to hear the name of a leg part." +

              "Then, click on the part\n that it names. If you are correct, the part will stay highlighted"+

              "If you would like to \n practice more, go back to try.";

               

               

               

              //title window container properties

              titleWindow.width = 450; //width

              titleWindow.height = 150; //height

              titleWindow.title = "HELP";  //title of pop up window

              titleWindow.addChild(label); //adds label to title Window

               

              titleWindow.showCloseButton = true; //allows the close button ("X") to be displayed

              titleWindow.addEventListener(CloseEvent.CLOSE, closeClicked); //event handler is called when close button is clicked that closes pop up box

              PopUpManager.addPopUp(titleWindow, this, true); //opens title window as pop up: true makes a modal pop up meaning you cant access the app until the window is closed

              PopUpManager.centerPopUp(titleWindow);  //centers pop up box on screen

              }

               

               

               

              //event handler: this closes the pop up window and is called when you click on the "X" in the top right corner of the pop up box

              private function closeClicked(event:CloseEvent):void

              {

              var titleWindow:TitleWindow = event.currentTarget as TitleWindow;

              PopUpManager.removePopUp(titleWindow); //pop up manager removes window from app

              }

               

               

               

               

               

               

              //links icon to the function

              <mx:Image x="560.5" y="10" source="icons/helpicon.png" width="70" height="60" click="launchPopUp()" />