2 Replies Latest reply on May 1, 2007 7:38 AM by Dilroy

    Creating textbox in actionscript

    Dilroy
      Hi,

      I have the following code to create a textbox in actionscript on the main timeline, but need to create it within a mclip:

      _root.createTextField("theTextBox",20,50,50,200,300);
      theTextBox.background=true;
      theTextBox.border=true;
      theTextBox.backgroundColor=0xFFFFFF;
      theTextBox.borderColor=0x000000;
      theTextBox.multiline=true;
      theTextBox.wordWrap=true;
      theTextBox.variable="myText";
      myTextFormat = new TextFormat();
      myTextFormat.font = "Arial";
      myTextFormat.size = 12;
      myTextFormat.color=0x000000;
      theTextBox.setNewTextFormat(myTextFormat);

      I'm sure that I need to change the '_root ' in the first line and replace with something like the instance name of the mclip,
      ie. _mclip1.createTextField("theTextBox",20,50,50,200,300);

      but I've tried this and it dosen't work.

      Any ideas will be much appreciated.

      Cheers

        • 1. Re: Creating textbox in actionscript
          dazzie Level 1
          You need to target the rest of the code correctly once the new clip is inside another clip (in this case 'myclip')... I found this works:-

          myclip.createTextField("theTextBox",0,0,0,200,300);
          myclip.theTextBox.background=true;
          myclip.theTextBox.border=true;
          myclip.theTextBox.backgroundColor=0xFFFFFF;
          myclip.theTextBox.borderColor=0x000000;
          myclip.theTextBox.multiline=true;
          myclip.theTextBox.wordWrap=true;
          myclip.theTextBox.variable="myText";
          myTextFormat = new TextFormat();
          myTextFormat.font = "Arial";
          myTextFormat.size = 12;
          myTextFormat.color=0x000000;
          myclip.theTextBox.setNewTextFormat(myTextFormat);

          myclip.myText = "test text";

          • 2. Re: Creating textbox in actionscript
            Dilroy Level 1
            It's ok i simply placed the code within the mclip and removed the '_root ' from the start. It seems to work ok now.

            Thanks for your help.