28 Replies Latest reply on Oct 3, 2007 9:08 AM by clbeech

    Mucho text, one Dynamic Text Field

    Mr. Aztek
      Okay, it didn't take me long to fudge this and I'm looking for the insight I know I don't have.

      I have 30 instances, each with the attached onRollOver/Out functions. Now I'm being told that in addition to that, text must appear in a field below, and each instance must call a different piece of text into the same text box. I already have AS creating the box with the following attributes:

      this.createTextField("txtAbstract", this.getNextHighestDepth(), 14, 352, 680, 85);
      txtAbstract.type = "dynamic";
      txtAbstract.multiline = true;
      txtAbstract.wordWrap = true;

      Ideally, to make this easier and scalable I would like to pull from an external text file (i.e., "abstracts.txt"), so that I can just have each abstract in the text file (#abstract1, #abstract2...#abstract30), that way when they want this project re-used, I just copy and paste the content into "abstracts.txt". This also means that I will need to have the text dissapear onRollOut (the text box remains blank until something is rolled over).

      So here are my questions:
      Can each instance have more than one onRollOver/Out event (one for the scale/slide and one to call from the text file and into a single dynamic text field)? The reason why it can't be an onClick is because that will be used to link people to a Web site in a separate browswer window.

      In either case, is it possible to call in different text from a single text file into the same text field? Or will it be easier to have separate text files per abstract? I'm not adverse to the latter...

      Any insight or help would be appreciated. Thanks!
        • 1. Mucho text, one Dynamic Text Field
          Greg Dove Level 4
          With your events ... I'm not sure I understand correctly. Why can't you just have each event trigger all the behaviours (i.e. call actionscript functions) that you want associated with it. So you just use the single event handler to do that....

          mcCategory1.onRollOver = function() {
          twScaleUp();
          showText(1); //for example - a function that displays the text at position 1 in an array
          }
          mcCategory1.onRollOut = function() {
          twScaleDown();
          hideText(); //for example a function that hides the text display
          }

          For the text in the external file, it might help you to read through these (similar to your request)

          http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1282393&highlight_key=y&keyword1=testimonial

          http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1280364&highlight_key=y&keyword1=testimonial
          • 2. Mucho text, one Dynamic Text Field
            Mr. Aztek Level 1
            Ahhh okay I think see now. I wasn't sure how to call more than one function on a single onRollover. I'll give it a shot and report back later. Thanks!

            One quick question, can I call different paragraphs of text from a single text file, or should I just make separate text files to get loaded into the text box?

            For example, the body of the text file reads:

            &txtAbstract
            #abstract1
            "Brief description 1"
            #abstract2
            "Brief description 2"
            (...etc.)
            • 3. Mucho text, one Dynamic Text Field
              Mr. Aztek Level 1
              Okay, I hit a snag and the onRollOver applied the scaling to the entire stage rather than each instance. Sorry for the confusion. I'll put up the entire code and hopefully it'll make more sense.

              What I want to have happen is that on each instance's onRollOver, different blocks of text from a single text file gets pulled into txtAbstract, and is removed/dissapears onRollOut. I would prefer this over an array because this will be easier to repurose for another use by simply swapping out the text file itself. I'm at a loss as to how to make that happen. Thanks for your assistance thus far!
              • 4. Mucho text, one Dynamic Text Field
                clbeech Level 3
                Holy Crap, Mr.A!!! why are there so many (36)?? are each of these one section of the drawers? but for six different categories? At least put each name in an array then cycle through, like below:

                Now I put the last line in there assuming that you may be wanting text in each of these sections. This would create a new field for each, I don't know about the dimensions though, there might be a better way I'm just guessing for now. but once set up, then you'd set up another function to feed new text in each time the drawer opens? is that how you want it?
                • 5. Re: Mucho text, one Dynamic Text Field
                  Mr. Aztek Level 1
                  quote:

                  Originally posted by: clbeech
                  Holy Crap, Mr.A!!! why are there so many (36)??


                  HA!

                  Yeah, I know. I'll be honest with you, I tried starting with an array--I even tried to have it place each instance for me--but I just could not get it to work. And when I can't get something to work the way I want it, I tend to "take the long way around the barn" as a fall-back. And yes, the text appears in the text field after it opens. Don't worry about the dimensions, there's supposed to be a text frame at the bottom of this 6x6 grid of buttons/drawers (the first row being the categories and the columns underneath them as items in said categories) that displays an abstract of the topic that's been rolled over.

                  quote:

                  Originally posted by: clbeech
                  Now I put the last line in there assuming that you may be wanting text in each of these sections. This would create a new field for each, I don't know about the dimensions though, there might be a better way I'm just guessing for now. but once set up, then you'd set up another function to feed new text in each time the drawer opens? is that how you want it?


                  Sooo long story short, yeah. I would like to have all of the abstracts in a single text file, making it easy for me to repurpose this in iterations that I know are to come.

                  So I'm seeing two different approaches here (I know both are correct): one is to have the text pulled from a single text file that has the src.split delimited into sections per GWD's suggestion, the other is to have the text field created each time AND pull the text per your suggestion (if I'm understanding you correctly). How would the text be "dumped" so that another can be pulled?

                  I'll be taking another deep dive at this tomorrow when I get back to work and report back to you all. I'll see if I can post the actual FLAs somewhere if you're curious and want to dissect my work. I know I'll definitely want to review this once it's finished so that I can learn how to better streamline my codewriting. Thanks again everyone, and stay tuned!
                  • 6. Re: Mucho text, one Dynamic Text Field
                    clbeech Level 3
                    Hey Mr.A - I've been kinda interested in this subject, so I did a little work on some of the principles you're working with here. One big hurdle your looking at is the listing mechanism for controling the button content. I think considering the amount of buttons your dealing with would recomend using XML in lue of name/value pairs in a txt doc. although this could work, I think that XML would keep it more organized, and easier to maintain.

                    I build a demo system for you to look at, I know it may not be just like what you have been working on, but I think the basic premis is here. Except that this system is totally dynamic, it creates all of the category buttons and drawer buttons completely based on the content of the XML document. You will notice when you open up the FLA that there is nothing on the stage, everything is propagated on loading the XML document. You can add or remove any category, or piece of information (node) and it will adjust and rebuild itself on the next test, just by changing the XML content.

                    The idea here is to show you how you can achieve this using dynamic data, and change it at any time, or for any page or so on. At this point, the drawer buttons do nothing except close up the drawer, they don't have any linking yet. but this is a simple matter of adding the link info to an '<href>' tag within the button's XML node contents, and flash will pick it up as a html URL link.

                    So check it out and see what you think, at least I hope it gives you some ideas :) FILE
                    • 7. Re: Mucho text, one Dynamic Text Field
                      Greg Dove Level 4
                      @clbeech : I agree with you that XML probably makes the most sense - its what I would choose as well. But some people prefer to use plain text. And for that you don't need to use name/value pairs. You can format it however like, so long as you implement your own parsing routine - its easy enough to create seperate array elements from the text by using the string.split method. Check out the links I posted earlier if you want to take a look at that as well.
                      • 8. Mucho text, one Dynamic Text Field
                        clbeech Level 3
                        I agree GWD, I know you could use the txt method too, didn't mean to dis your method there :) It most certainly would function as well. I just went with XML for my own sake, I guess, working on some things in that area. And It also seemed that with the quantity of info he's trying to shuffle around, XML layout might be better for clarity ... nice and neat ... I dunno?? seemed like this way he wouldn't have to worry about getting the string setup right, or missing a delimiter or something.

                        (btw - I love your signature line, I smile every time I see it :)
                        • 9. Mucho text, one Dynamic Text Field
                          Greg Dove Level 4
                          @cbeech - hey no offence taken... nor do I consider it my method, lol. I just saw your comment about having to use name/value pairs and wanted to make sure you knew that's not a constraint. You'll see in the other threads above that I was actually encouraging use of XML as well. In terms of missing delimiters etc... well basically I don't see a difference. If you're manually typing xml in notepad for example you could also easily make a mistake - perhaps its even easier - that's what the guy in other threads above was saying, he wanted something more simple an easier to maintain. You could use a proper xml editor or use something else to check/validate your xml I guess, which is a difference, but probably not relevant here.
                          Like I said though, I'd use XML. The main reasons I'd do that is that you have native support for it in flash - and its a standard way of representing data, so its easy to change later on.

                          re the signature line... I like it too. I'd love to say I came up with it myself, but I didn't - I can't remember where or when I first saw it, but it was some time ago. There was some binary-related question recently that made me remember it.
                          • 10. Re: Mucho text, one Dynamic Text Field
                            Mr. Aztek Level 1
                            Hey guys,

                            Wow, looks like I've got the "issue du jour" with this one. Thanks CB for the file, I've been dissecting it all afternoon.

                            But in my case, I would prefer to go the text file route, only so that when I get the next update from my client, I can just swap out text files. But I am going to keep the XML option open (I've used a similar approach in a slideshow). I've put up my files to see if it helps get a better understanding on what I'm trying to do.

                            Here's what I'm working on (my apologies to my friend for borrowing her space to upload the file):

                            FILE

                            I'm still struggling getting the onRollOver to perform more than one function (the tween scales/drawer slide AND call text into a dynamic text field). It either removes the functionality compeltely or scales the entire stage. I know I'm getting the syntax wrong somewhere but I keep hitting a wall...
                            • 11. Re: Mucho text, one Dynamic Text Field
                              clbeech Level 3
                              Hey Mr.A - looking at the file now. Are you wanting text to be displayed in the box below, when you click on the drawer drop down?
                              • 12. Re: Mucho text, one Dynamic Text Field
                                Mr. Aztek Level 1
                                Hey CB, thanks for peekin' into it!

                                Not quite. I would like for the text to be displayed during the roll over.

                                The intent is to have the user check out all of these attributes, see what applies to them, get a brief description of each sub/category in the text box below as they roll over each one, and if they're intereted, then they will click on the button/drawer, which will then open an URL in a separate browser window (hence why I'm saving the onMouseUp event for that).
                                • 13. Re: Mucho text, one Dynamic Text Field
                                  clbeech Level 3
                                  I see, no problem, we can get it. We'll just delimit the text file (you want to use '[Abstract]' right?) and put the strings in an array, and assign them to the textfield on rollOver. I should have something for you in a little bit.
                                  • 14. Mucho text, one Dynamic Text Field
                                    clbeech Level 3
                                    Hey Mr.A - OK I've gotten a chance to go over this. I've made some pretty drastic changes, you don't have to use any of it though ;) Just thought I could help tiddy things up a bit for you. I've connected the Loadvars system and have included an example text file just for checking, except I just haven't been able to get the line break out of the string yet (GWD !!!). I also changed the way the the on handlers work, more in line with the version I'd constructed earlier. This way, the box will remain open if you move