2 Replies Latest reply on May 25, 2011 9:25 PM by rustyuser

    Set the amount of text externally acquired in Flash project?

    rustyuser

      Hello Flash gurus!!...... hopefully..

       

      I am a VERY basic user with Flash and have been asked to make an auto-scrolling news ticker for our website.  The ticker needs to be able to pick up text from an external text file (so that we only need to alter the text file rather than the .fla file).  AND, if possible, it needs to update automatically each day... I'll explain in more detail as I imagine this is very hazy so far.

       

      The news ticker will display up-coming events for the following two weeks on our website.  So on, say, Monday the 1st it will show something like:


      Monday, 1st                    Executive Business Meeting


      Tuesday, 2nd                  Board meeting


      Wednesday, 3rd              Queen's Birthday Public Holiday


      ....


      ...


      ..


      Sunday, 14th                   Company Golf Day

       

       

       

      So on Monday the 1st, it will show all of the events on loop, for the next two weeks, scrolling upwards.  For the next day, Tuesday the 2nd, I want it to no longer show the details from Monday the 1st as it is past that date and it should now also include Monday the 15th on the ticker.  Make sense??  I hope so..

       

       

      So I started from the bottom, looking up help here and there and have now got to the stage where my project is as follows:

       

      In the exported movie from my working project the text is acquired from an external text file.

      The text starts where I want it to and it scrolls upwards also (all going to plan).

      ~problem~ after about one week of up-coming dates has scrolled up, the text gets cut off!

       

      My question therefore is:  "How do I select/alter the amount of text that is acquired from my external text file???"

       

       

      Project Details:  I am using ActionScript 2.0, I'm operating on Mac OS (not that it matters), I have a full year of dates I can utilise in the text file.

       

      How I have done what I have done:  I inserted a text box. Changed the properties to dynamic text, character embedding to "all" and under variable I wrote "content."  I my text file I wrote "content=", followed by all of the dates and information I want in the news ticker.  I saved both the project and the text file in the same location.  In flash, I made the text box large enough to fit months of dates inside.  I made the layer a 500 frame motion tween.  I inserted a keyframe in the last frame of the motion tween.  With this last keyframe selected, I moved the text box up and completely above the stage until all of it was above.

      ^ that was all basic, the next part is using the external file (which is also quite simple I guess).

       

      I created another layer.  I went into actions of this new layer and now have it reading:  loadVariablesNum("Date.txt", 0);

       

       

      ..I think that is just about everything I have done.  When I preview my project as a movie, it all goes well but then the text cuts off after about a week of dates being listed.  I want to know how to get it to display more (all) of my text and, if possible, specific sections of my text of which I choose.

       

      Please Help Kind People  :S

        • 1. Re: Set the amount of text externally acquired in Flash project?
          Ned Murphy Adobe Community Professional & MVP

          You can get some ideas here, but it'll be up to you to pursue trying to get things working... there are a one or two here that will do all the work for you if you get lucky... but I'm not one of them.

           

          If you want to control how much of the data you display based on certain criteria, then you need to make that criteria readily determinable in the data.  So you'll need to work out some data structure/storage elements.

           

          If you had a formal external database, such as a MySQL database, you could send a query and have it return only the items that satisfy some criteria you provide for particular fields, such as the event date.

           

          In your current design you can't really control how much data you pull into the file because you have to process the data first to determine what portion of it you want to display... and to do that you have to pull all of the data in and scrutinize it.

           

          So if you plan to continue with the text file approach, you will need to load all of the data and then process that data such that you can isolate the criteria that you will use to limit what ends up being displayed.  If the date is the single bit of information in a set that will decide whether to include something or not, then for each set you need to be able to isolate the date information.

           

          Look into how to use the String.split() method to break your 'content' into an array, likely using it a couple of times to isolate the date element from the event description element.  In your text file you could have each event set separated by commas, and each element in a set separated by dashes.  So first you use the split method to first create an array of the data sets...  dataArray = content.split(",");  and then you loop thru that and break apart each element of the array for the individual fields...  dataArray[i] = dataArray[i].split("-").  Here's a basic example...

           

          var content = "06/02/2011-event 1,06/02/2011-event 2";

           

          var dataArray = content.split(",");

           

          trace(dataArray);

           

          for(i=0; i<dataArray.length; i++){
             dataArray[i] = dataArray[i].split("-");
             trace(dataArray[i][0]);
             trace(dataArray[i][1]);
          }

           

          You'll notice I used the trace command in that code.  Learn to make use of it while you are designing this.  It helps you to see whether or not your code is processing things the way you expect it should.

           

          You might find it easier to work out down the road (after the learning curve) if you use an xml file for your data rather than the way you have the data file now.  It is still a text file, but it is written in a tag-formatted manner that can make it a bit easier to track down and isolate the data.  Flash has methods specifically for processing xml data.

           

          The key to it all in any case is getting the data in and processing it before it ever gets assigned to the final display vehicle (your textfield in this case).

           

          Lastly, get away from using the variable aspect of a textfield.  Give the textfield an instance name and assign text to it using the 'text' property.  Using the variable approach can be problematic and could have you wasting time solving the wrong problem.  Its hard to say if that's part of the current problem.

          1 person found this helpful
          • 2. Re: Set the amount of text externally acquired in Flash project?
            rustyuser Level 1

            Thank you so much for such a comprehensive response Ned!

             

            But I'm sorry, I got a bit lost in your words - I am a REAL beginner in Flash.

             

            Like, we do have SQL but I wouldn't know where to start to link to it or "send a query" :S  ...

             

            I tried using your action scripts but didn't see how it would use an external text file?  Or did you intend me not to do this and the script utilises imported text into my text box?  Because I tried that and separated the way you said but it ended up just coming out in one horizontal line which means hardly any of the data is actually seen.

            Or did you intend me to keep using the action script I already had in there also??

             

            I dunno, it just all feels a bit out of my depth :/

             

             

            From everything you said I still don't know how to make it display a specific area of the text and to make it update automatically each day...

             

            Sorry - this must be very frustrating dealing with someone who can't understand and brings you back to basics.

             

            I understand if you just want to tell me to go chew through a heap of flash tutorials or read Flash for Dummies or some junk

             

            Thanks again Ned.