6 Replies Latest reply on Jan 29, 2008 11:18 PM by zer0efx

    Get height of a dynamic text field: even possible?

    zer0efx
      Is there a way I can read the height from a dynamically generated text box into a parent movieClip for positioning purposes?

      I have a single line text box set to autoWrap and autoSize.
      My attachMovie function only see's this as a single line object even if I have 3 lines. So the text will display all fine, but when it stacks the next movie clip, it stacks on top of the previous one. But it stacks under the height of the single line text box i created.

      I can of course increase the height of the text box, but then that defeats the purpose of the auto settings. Plus, some nodes have 1 line, some have 6 so I need them to adjust accordingly.

      ideally:
      Box 1 height = 45 so y position starts at 0,0
      Box 2 height = 108 so y position starts at 0,55 (10 pixels below the first box)
      Box 3 height = 36 so y position starts at 173 (the first box, plus the second box, plus the 10 pixels in between both)

      I can't seem to get this to work the way I'd like it to. I would appreciate any insight. I've been all over Google and haven't been able to find much of a reference.

      This is the code I have:


      Thank you!!
        • 1. Re: Get height of a dynamic text field: even possible?
          Rothrock Level 5
          I'll probably mess up the exact terminology, but the methods and properties of children of an attached movie are not available until one frame after the attaching happens. Or something like that.

          So you could wait one frame and then reposition everything, or ....

          I would recommend not using attachMovie and instead create your textFields dynamically. You can then place them where you want them. If you have some reason that the textFields each need to be wrapped in a MovieClip you can still do that with a combination of MovieClip.createEmptyMovieClip() and MovieClip.createTextField().

          Post back if you need help with implementing that.
          • 2. Re: Get height of a dynamic text field: even possible?
            zer0efx Level 1
            Thanks for the reply Rothrock!

            The reason I'm using the attachMovie is because the clip I attach is the base template for that XML node. This MC checks the XML file and fills in the data accordingly.

            So in my ActionScript, I grab the "Title" and "File" attributes and feed it to a text instance. The second thing I do on this, is check if a <doc> node has a childNode <list>. It it does, then attach the next clip and then duplicate for those items.

            Below is the XML and then the Actionscript for the <doc> node:
            • 3. Re: Get height of a dynamic text field: even possible?
              zer0efx Level 1
              I'm really confused with all this. I def could be doing this the wrong way, but it seems what I am trying to do isn't that hard.. but obv. is.

              I've been starting at this stuff so long and I feel like I have tried dozens of methods.

              Here's an example of what the above code produces.
              iFOB Presentation

              I really appreciate the time! I'm getting towards my witts end
              • 4. Re: Get height of a dynamic text field: even possible?
                Rothrock Level 5
                Right......?

                So is there a reason you can't do the following (bold for my version of what happens):

                So in my ActionScript, I grab the "Title" and "File" attributes and feed it to a text instance I just dynamically created with createTextField. The second thing I do on this, is check if a <doc> node has a childNode <list>. It it does, then create another text field and then duplicate for those items.

                A bit, but not much, different from what I'm seeing except this will allow you to get the _height as you go.

                The other solution is just to attach all the movies, keeping them hidden, but not worrying about placement. Then after a frame has gone by, stack them and unhide them.
                • 5. Re: Get height of a dynamic text field: even possible?
                  zer0efx Level 1
                  quote:

                  Originally posted by: Rothrock
                  Right......?

                  So is there a reason you can't do the following (bold for my version of what happens):

                  So in my ActionScript, I grab the "Title" and "File" attributes and feed it to a text instance I just dynamically created with createTextField. The second thing I do on this, is check if a <doc> node has a childNode <list>. It it does, then create another text field and then duplicate for those items.



                  Ohh YEAH!! Thats exactly what I want to do, and I guess what I am doing with the attachMovie. But with that, I am essentially creating 3 MovieClips because of 3 list items.

                  If I can make this easier, i would love to!
                  • 6. Re: Get height of a dynamic text field: even possible?
                    zer0efx Level 1
                    Finally! I got it!!! My last attempt before I turned the monitors off.
                    Just need to write a statement that if no list exists, don't use it in the curHeight you had helped me with.

                    *phew! glad that problem is solved!

                    Thanks!