7 Replies Latest reply on Jul 5, 2006 3:42 AM by ricklecoat

    String variable not being passed properly

    ricklecoat Level 1
      I've got a situation where I have set up three string variables (teamName:String, teamRole:String and teamBiog:String) on the root timeline and am trying to pass them to three dynamic text fields nested a couple of clips deep inside an MC. The path (from the root) to the text field that will receive the teamName variable is:
      this.texthandler_mc.name_mc.name_txt

      (the other two text fields have similar paths).
      The variables are called from the first frame of the textHandler_mc, and so are referred to as _root.teamName etc.

      However, when I try to pass the variables to the text fields, either nothing happens or the string is corrupted. As a test I set teamName:String to "Mr Jones" and when it arrived at the text field it read "M Joe". The other two text fields, which had also been passed variables, were unchanged from their initial text -- the variable had seemingly not arrived.

      It's got me stumped and I'm hoping somebody can help.

      Here's the code; it's not all in one place so I've annotated it to show where the code pieces reside.
        • 1. Re: String variable not being passed properly
          kglad Adobe Community Professional & MVP
          does frame 17 or your _root timeline play before frame one of textHandle_mc? if not, remedy that. if so, post a link to your fla.
          • 2. Re: String variable not being passed properly
            ricklecoat Level 1
            Uh, they should be simultaneous I think. textHandler_mc first appears in frame 17 of the timeline, so I would think that they both kick off at the same time.
            Here's the fla file in case it helps...
            http://tinyurl.com/nvsl2
            • 3. Re: String variable not being passed properly
              ricklecoat Level 1
              Forgot to add: in the FLA the problem occurs in the second scene, "the Team".
              I also tried moving the code setting up the variables to frame 1 of that scene, but it made no difference to the result.
              Thanks.
              • 4. Re: String variable not being passed properly
                kglad Adobe Community Professional & MVP
                no code execution is simultaneous in flash. when a _root timeline frame "plays", the code on the _root timeline executes first, then the code in the first frame of any movieclips that are attached to that frame execute.

                so, you're ok with the order of code execution when you assign the text property to name_mc.name_txt. your variables are defined first and then the textfield's text property is assigned using those variables.

                however, when you (try and) assign the text property to role_mc.role_tx and biog_mc.biog_txt, those textfields (and their parent movieclips) don't exist. they won't exist for 2 and 5 frames, respectively after you try and assign their text property. that's not going to work.

                you must wait until an object exists before you can control any aspect of that object. in your situation, move the text assignment statements to the frames where your parent movieclips and the child textfields are instantiated.
                • 5. Re: String variable not being passed properly
                  ricklecoat Level 1
                  kglad:
                  now that you explain it that way it does make perfect sense, thank you. I have now split up my 3 text field assignment code lines so that they each appear on the relevant frame (ie. the first frame where the target instance makes an appearance) rather than putting them all on the first frame, and that has solved the issue of the 2nd and 3rd strings not getting to their destinations.

                  I've still got the problem of the corrupted results though. On the first two strings, "Mr Jones" comes out as "M Joe" and "Executive" comes out as "Eee".
                  The third string passes fine however, and the only difference I can tell between the text fields (apart from font size and colour) is that the first 2 are single line, whilst the 3rd is multiline with wrap. [ Extra: I just changed the fist and second text fields to multiline, but the problem persists.]

                  Any ideas on this weird aspect? It's not a straightforward truncation, and the text fields themselves are large enough to accommodate the strings.

                  Thanks for all your help this far, I hope you'll have a simple solution to the last bit as well!
                  Rick
                  • 6. Re: String variable not being passed properly
                    ricklecoat Level 1
                    kglad:
                    now that you explain it that way it does make perfect sense, thank you. I have now split up my 3 text field assignment code lines so that they each appear on the relevant frame (ie. the first frame where the target instance makes an appearance) rather than putting them all on the first frame, and that has solved the issue of the 2nd and 3rd strings not getting to their destinations.

                    I've still got the problem of the corrupted results though. On the first two strings, "Mr Jones" comes out as "M Joe" and "Executive" comes out as "Eee".
                    The third string passes fine however, and the only difference I can tell between the text fields (apart from font size and colour) is that the first 2 are single line, whilst the 3rd is multiline with wrap. [ Extra: I just changed the fist and second text fields to multiline, but the problem persists.]

                    Any ideas on this weird aspect? It's not a straightforward truncation, and the text fields themselves are large enough to accommodate the strings.

                    Thanks for all your help this far, I hope you'll have a simple solution to the last bit as well!
                    Rick
                    • 7. Re: String variable not being passed properly
                      ricklecoat Level 1
                      I had just typed a reply explaining that the issue of the string looking corrupted at its destination is resolved. However, once again the forum server just sat churning for 10 minutes or so before timing out with 'Server stopped responding'. (this server trouble is also responsible for the duplicate posting above). My reply was lost, and I don't have the time to retype it, so suffice to say that the problem is resolved. Thanks kglad for your help in sorting out the non-instantiated symbols problem.

                      I just wish this forum server worked better; I find it almost unusable, and it stands in stark contrast to the superb quality of help that the forum member provide.