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 your cursor down to the 'click here' line so that you'll be able to click it ... :) I didn't put any functions in for this, and I didn't have the Minion font in my system so it was all a little weird. I changed the textfield creation and formating you had in there, it's not necessary to do this in the code, you can just place one on the stage and set the pararmeters that you wanted, I did this. Note: dynamic textfield need to be embedded individually, you can't make a single field that 'embeds' the font, although you can 'embed' a font within the document through the Library, but you have to then assign it to a field with the setTextFormat method, not necessary here.

                                    I also threw in the alpha transition you were going for :)

                                    Take a look see what you think, then you can start working on the URL links.

                                    EDIT!!!!!! dang!!!! the FILE is in the post below .....
                                    • 15. 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 your cursor down to the 'click here' line so that you'll be able to click it ... :) I didn't put any functions in for this, and I didn't have the Minion font in my system so it was all a little weird. I changed the textfield creation and formating you had in there, it's not necessary to do this in the code, you can just place one on the stage and set the pararmeters that you wanted, I did this. Note: dynamic textfield need to be embedded individually, you can't make a single field that 'embeds' the font, although you can 'embed' a font within the document through the Library, but you have to then assign it to a field with the setTextFormat method, not necessary here.

                                      I also threw in the alpha transition you were going for :) Here's the new file: FILE

                                      Take a look see what you think, then you can start working on the URL links.

                                      EDIT!!!!!! sorry for the double post, thought I'd canceled before it went ... dang! ;)
                                      • 16. Re: Mucho text, one Dynamic Text Field
                                        Greg Dove Level 4
                                        @clbeech : Its looking good.
                                        To get rid of the linebreaks, you can just include that in your delimiter for the split - This probably makes sense because you then use the delimiter on a separate line... or you could remove them from the strings after the split.
                                        You could make the split sequence "\r[Abstract]\r" to get rid of trailing line breaks as well.

                                        Different OSes represent the line breaks in different ways. As far as I know there are 3 ways.
                                        Anyhow I think this will work regardless of the text file source...(I know the windows fix works):

                                        //load txt file
                                        var load_lv:LoadVars = new LoadVars();
                                        load_lv.onData = function(scr:String) {
                                        //windows source files
                                        scr=scr.split("\r\n").join('\r');
                                        //can't remember what OS this is:
                                        scr=scr.split("\n").join("\r");
                                        lvAbstract = scr.split("[ABSTRACT]\r");
                                        }
                                        load_lv.load("Abstract.txt");
                                        //:::::END Abstract text load and store
                                        • 17. Re: Mucho text, one Dynamic Text Field
                                          clbeech Level 3
                                          @GWD, hey thanks man. I knew I'd seen that split line around somewhere, but couldn't remember, I'd tried a variation I think it was, s("\r").j(""); ... just haven't used plain text files much ...lol :) and I hadn't really grasped the full meaning of the subject you'd linked to earlier (went back and took a more thorough look), and wow can I see the ease of use now! I think actually easier to parse the scr string than iterating through the XML nodes .... HA! especially if dealing with large blocks of text.

                                          right on :)
                                          • 18. Re: Mucho text, one Dynamic Text Field
                                            Greg Dove Level 4
                                            @cbeech. Yeah, the onData method lets you hijack the raw text data (actually you can do the same with the XML.onData method as well... you could just as easily use that instead of LoadVars) . I wondered earlier if you'd 'got' the point about not needing to use the name/value pairs like a regular LoadVars. Sorry I didn't explain more clearly here, but I did a lot of typing in that other thread and was being lazy.
                                            Once you get used to it, its kinda easy yes... but I still personally would use XML in preference whereever I could, even if it seems a bit more work - but hey to each their own.
                                            • 19. Re: Mucho text, one Dynamic Text Field
                                              Mr. Aztek Level 1
                                              (gets up off floor after being knocked out of his chair)

                                              That is AWESOME. You guys have really saved my bacon in terms of doing things the long way around (don't ask...it was going to involve timeline/frame lable jumping; effective, but overly tedious and not easily scalable). There's still a very minor bug in the roll overs don't always happen immediately and there doesn't appear to be a consistent factor, but given the choice between the "jittery" and the miss, I'll take the latter!

                                              Thanks so much to the both of you for your input (CB, that's two I owe you now). While I definitely agree XML is more efficient and allows a higher degree of control, I can now just give this text "template" to my clients and they can simply put in the content and give it back to me when they are ready.

                                              Odds are this is going to be live within two weeks, and I'll be more than happy to share the finalized product. Thanks again!
                                              • 20. Re: Mucho text, one Dynamic Text Field
                                                Mr. Aztek Level 1
                                                Okay...LAST question...

                                                I need the text field to be blank until a button is rolled over, do I just add a "blank" (e.g. a space) abstract in the text file as a placeholder?
                                                • 21. Re: Mucho text, one Dynamic Text Field
                                                  clbeech Level 3
                                                  Great Mr.A, you're welcome. I had also noticed the 'flaw' in the RollOver/Out methods too, I think it might be due to the scaling overlaping the next hit area, not sure, try turning the scale down a little and see if that helps, maybe make the tween a little faster too, this might help 'catch' the next event sooner.

                                                  You've still got some things to do yet with the other events, and then getting the links set up (I'm thinking a separate text file and another LoadVar might be simplest, although you could get it out of the original text file string)

                                                  Let us know if you need more assistance, we've got your back :)

                                                  @GWD, yeah...lol...sometimes I just get stuck doing what I know, instead of trying something new ;) But that's great, one of my mantras is 'learn something new everday'... so you would think ... lol!
                                                  • 22. Re: Mucho text, one Dynamic Text Field
                                                    clbeech Level 3
                                                    hmmm... do you mean you want it blank when someone is not over a button?
                                                    • 23. Re: Mucho text, one Dynamic Text Field
                                                      clbeech Level 3
                                                      Ok, if you've left the code I had there, add this to line 80:

                                                      Abstract_txt.text = "";

                                                      it should be located within the 'hitTest' that sends the buttons back to their normal state, we're just putting a null string into the field. done deal :)
                                                      • 24. Re: Mucho text, one Dynamic Text Field
                                                        Mr. Aztek Level 1
                                                        Sweet!

                                                        Yeah, I have some placeholders for the yet-to-be-created sound (which, to be honest is the least of my concerns at the moment), and I plan to have an onMouseUp event to link to an URL that opens in a new browser window, but I don't have the links yet.

                                                        I'll fiddle around with the scaling and speed to get it just right. Thanks!
                                                        • 25. Re: Mucho text, one Dynamic Text Field
                                                          clbeech Level 3
                                                          No sweat, keep us updated :)
                                                          • 26. Mucho text, one Dynamic Text Field
                                                            Mr. Aztek Level 1
                                                            It's still alive and kicking!

                                                            Unfortunately the client liked it so much, they are still making cosmetic changes and pushing back the release date by a week. HA! Ah well, at least it's just cosmetic changes.

                                                            Blah.

                                                            Nontheless I've finally had a chance to work on the second half of this module and have hit a small snag, I've started a new thread about it
                                                            <a target=_blank class=ftalternatingbarlinklarge href="[L=http://"<a]http://"<a[/L] target=_blank class=ftalternatingbarlinklarge href="[L=http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=288&threadid= 1299988">http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=288&threadid=1 299988">HERE.</a></a>[/L]]http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?cat id=288&threadid=1299988">http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?cati d=288&threadid=1299988">HERE.</a></a>[/L][/L]
                                                            • 27. Re: Mucho text, one Dynamic Text Field
                                                              Mr. Aztek Level 1
                                                              Final post on this subject:

                                                              Just wanted to give a grategful acknowlegement to the contributors on this thread. The project I used this one is now being deployed (but not public-facing, much to my dismay...I'd love to show the final results to you all) to our membership and has caught the attention of the executives. They liked it so much that they have asked other programs within the company to utlize the Flash project across the company. I could not have done it without the insight and help I recieved here. So a big THANK YOU to you all!
                                                              • 28. Re: Mucho text, one Dynamic Text Field
                                                                clbeech Level 3
                                                                congrats MrA, there you go!! job security LOL!!!!!

                                                                and you're welcome :)