Pulling text from a .txt to a scroll pane or text area

Hi-
I'm sure there's a way to do this, but I'm not exactly fluent in ActionScript.
Basically, my whole website's going to be in Flash, but I want to be able to update one page (sort of a news/blog page) without having to edit the Flash file every time. I'm assuming the easiest way to do this would be to set up either a scroll pane or a text box and pull the text in from a .txt file (if there's a better way, please let me know). That way I could continue to add on to the .txt file, and Flash would always pull in the current version.
So, my issues are:
1. I have no idea where to start with the code for something like that. Is it a LoadVar? Do I physically put a scroll pane or a text area in the frame and put the action on that, or do I put the action on the frame and have it call up a text area component?
2. Will the text scroll automatically, or is that something else I would have to add in? I plan on adding to this text file for awhile, so it could end up being a lot of text over time.
3. Would I be able to format the text in the .txt at all? For instance, if I hit enter to put in a paragraph break, would that register once it's pulled into Flash, or would I have to put in an html paragraph break or something? That may be a dumb question, but as I said, I'm not exactly fluent in ActionScript (or any other programming language for that matter).
Any help is definitely appreciated!
Thanks!
-Geoff

I recommend you use an xml file rather than a text file for storing your content.  The main reason being that it tends to make thing more easily organizable, as well as easier to differentiate things like titles, contents, links, images, etc.
You could start off using a TextArea component if you want, just to keep things simple.  If you want to format things you can use the htmlText property rather than the text proiperty when assigning your content.  That will allow you more control of the presentation.
If you want to take the xml approach, you should search Google for "AS# XML tutorial" where you substitute whatever version you plan to use for the "#".  If you plan to use AS3, there is a good tutorial here: http://www.gotoandlearn.com/play?id=64

Similar Messages

  • Importing Text From A .txt File

    Hey guys,
    I'm looking for a way to import text from a .txt file but I'm totally lost. If someone could point me in the right direction that would be awesome

    Hi Prails
    This script is basically what you asked:
    #target illustrator
    #targetengine main
    function copyText(){
        var textFile = File.openDialog ("Select the file");
        if (! textFile.exists || app.documents.length==0){
            return;
        textFile.open("r");
        var txtContent = textFile.read();
        textFile.close();
        var doc = app.activeDocument;
        var textItem = doc.textFrames.add();
        textItem.contents = txtContent   
    copyText ();
    Basically what you need to do is declare the text file, open it, read the content and close it. Then, you create a new text item in the Illustrator document and write the content once catched into the text item.
    You could continue to work with the variable "textItem" in my example script if you want to set properties like the size, color of the text, position and so on. Also, if you want, replace the first line of the function var textFile = new File ("~/Desktop/Test.txt"); by var textFile = File.openDialog ("Select the file"); so the scripts opens a dialog to ask you the file you want the copy the content.
    Hope to be helped
    Best Regards
    Gustavo
    Message was edited by: Gustavo Del Vechio

  • Loading text from a .txt file

    I want to do something that should be VERY simple, but due to
    Adobe's insistence on using #$%^ing tutorials instead of just
    providing step by step instructions, it's very frustrating to
    figure out how to do it.
    All I want to do is load the contents of a text file into a
    dynamic text field, but I can't figure out how to do it (I'm not
    all that familiar with AS). I'm working with Flash 8. Please help.
    Thanks.

    Create the dynamic text box, and name it schedule.
    Then, in the frame on the timeline that the text box resides
    in, the corresponding actionscript would be used to create a text
    variable and assign the text from a txt file to it:
    loadText = new LoadVars();
    loadText.load("externalfile.txt");
    loadText.onLoad = function() {
    schedule.text = this.textbody;
    Where does the "textbody" variable come from? In the external
    text file (externalfile.txt in this example), you have a variable
    called textbody, and the externalfile.txt should read along the
    lines of:
    textbody = "I'm the external text that needs to be read
    in"

  • How to import text from Word and retain italics and/or indented text?

    Is it possible to import or copy text from Word into InDesign and retain italics or text that is indented in the Word version?

    just wanna edit wrote:
    Thank you, I think I understand the idea of "place" (which is what I would call "paste")
    The two are not at all the same. Paste involves copying text to the clipboard and then pasting from the clipboard. Place is an import operation.

  • Myself and my partner had a iphones. Since the recent software update he now randomly receives texts from my contacts and also when im sending texts. Is this because we share the same apple id. This didnt happen before the software update.

    myself and my partner had a iphones. Since the recent software update he now randomly receives texts from my contacts and also when im sending texts. Is this because we share the same apple id. This didnt happen before the software update.

    You can both share the same Apple ID for purchases but i suggest one of you use another email for the use of iMessage, Facetime etc.
    It is easy to do, the easiest way is to set up an iCloud email directly from your iPhone. Once set up one of you will use this for iCloud services but both still use the existing Apple ID to make purchases.

  • HT1688 Is there an "easy" way to either 1) cut and paste a large block of text from the Messages app or 2) access this text through a computer?

    Is there an "easy" way to either 1) cut and paste a large block of text from the Messages app or 2) access this text through a computer?

    Tap and hold the text you want to copy, then tap Copy.

  • IPhone6 is not sending or receiving texts from non-Apple users, except when in Group texts. I've tried the various fixes on the main support page to no avail. Any ideas?

    iPhone6 is not sending or receiving texts from non-Apple users, except when in Group texts. I've tried the various fixes on the main support page to no avail. Any ideas?

    Have you contacted your carrier to make sure there's no issues with your account?
    ~Lyssa

  • How to use automator to extract specific text from json txt file

    I'm trying to set up an Automator folder action to extract certain data from json files. I'm pulling metadata from YouTube videos, and I want to extract the Title of the video, the URL for the video, and the date uploaded.
    Sample json data excerpts:
    "upload_date": "20130319"
    "title": "[title of varying length]"
    "webpage_url": "https://www.youtube.com/watch?v=[video id]"
    Based on this thread, seems I should be able to have Automator (or any means of using a shell script) find data and extract it into a .txt file, which I can then open as a space delimited file in Excel or Numbers. That answer assumes a static number of digits for the text to be extracted, though. Is there a way Automator can search through the json file and extract the text - however long - after "title" and "webpage_url"?
    json files are all in the same folder, and all end in .info.json.
    Any help greatly appreciated!

    Hello
    You might try the following perl script, which will process every *.json file in current directory and yield out.csv.
    * CSV currently uses space for field separator as you requested. Note that Numbers.app cannot import such CSV file correctly.
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - *.json > out.csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    For Automator workflow, you may use Run Shell Script action as follows, which will receive json files and yield out_YYYY-MM-DD_HHMMSS.csv on desktop.
    Run Shell Script action
        - Shell = /bin/bash
        - Pass input = as arguments
        - Code = as follows
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - "$@" > ~/Desktop/out_"$(date '+%F_%H%M%S')".csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    Tested under OS X 10.6.8.
    Hope this may help,
    H

  • When I send a text from my imac friend with verizon receives duplicate text

    When I send a friend a text from my imac she receives it in duplicate. She has Verizon. But when I send her a text from my Verizon phone she only gets it once. Any ideas why?

    Hi,
    Are you using Mail to send these text messages? My experience has been that Mail always sends the text of a message twice. I don't use Mail but my wife and father do, and their messages are often repeated. I think. Maybe there's some way to avoid this by using particular settings in Mail. I would recommend turning off any fancy font settings, and not putting in any attachments, and see if the messages are still duplicating the text. I'm going to try that myself when I get a chance.
    Andy

  • I can receive a text from a contact but cannot send to them- both are iPhone with IOS 7

    I can receive a text from one of my contacts but when I send a text back, the text is not delivered.  We both have updated iPhone 4s phones.  Neither of us is blocking and we were able to text both ways until one of us made some changes due to a son's iPod being added -then tried to change back- still doesn't work.  Any suggestions?

    Hi sailsurf21,
    Thanks for using Apple Support Communities.  This article has some steps that may help troubleshoot issues sending messages on your iPhone and receiving messages on theirs:
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/ts2755
    Cheers,
    - Ari

  • Importing fixed width text from a .txt file

    I am really struggling to do in Numbers '09 something which I can do easily in Excel.
    I have a txt file containing plain text in fixed-width columns which I would like to import into numbers.
    I just cannot find a way to do it.
    I have tried using the Insert/choose menu item - but it won't take .txt files.
    I have tried to copy/paste the data, but it get's pasted into a single column.
    The data consists of many lines like this:
    Part Value Device Package Library Sheet
    A-IN JST-2.0-4 JST-2.0-4 JST-20M KMILLAR 1
    A-IN JST-2.5-4 JST-2.5-4 JST-25M KMILLAR 1
    A-IN JST-2.8-4 JST-2.8-4 JST-28M KMILLAR 1
    (and so on....)
    (Each column is an exact number of characters wide, but these forums make that hard to see due to the variable spaced fonts).
    How can I import this data into numbers?
    (Sorry, but I cannot get the data in any other format, such as CSV, the application which exports it only support fixed width colums with spaces for padding).
    Many thanks in advance,
    Kenny

    Here is a script treating the case of fixed widths values.
    --[SCRIPT fixedwidth_values_toTSV.scpt]
    Enregistrer le script en tant que Script : fixedwidth_values_toTSV.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    aller au menu Scripts , choisir Numbers puis choisir fixedwidth_values_toTSV
    Choisir un fichier texte.
    Le script détermine la largeur des différentes colonnes puis remplace les groupes séparateurs par des caractères TAB.
    Le résultat est passé dans le presse-paiers et est enregistré à la place du contenu initial.
    Vous pouvez alors
    (1) coller dans le document de votre choix
    (2) ouvrir le fichier texte modifié dans Numbers qui accepte sans broncher les ficiers .txt.
    Utilisation alternative : enregistrer le script en tant que Progiciel (Application sous 10.6.x)
    Glisser-déposer l'icône d'un fichier texte sur celle de l'application lancera le traitement voulu.
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    Sous 10.6.x,
    aller dans le panneau "Général" du dialogue Préférences de l'Éditeur Applescript
    puis cocher la case "Afficher le menu des scripts dans la barre des menus".
    --=====
    Save the script as a Script: fixedwidth_values_toTSV.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    go to the Scripts Menu, choose Numbers, then choose "fixedwidth_values_toTSV"
    Choose a text file.
    The script scan the file's contents to extract the width of every column then it replace the separator groups by TAB characters.
    The result is passed to the clipboard and is written in the original file.
    So you may :
    (1) paste in the document of your choice
    (2) open the modified text file with Numbers which is fair enough to do that.
    An alternate track is to save the script as an Application Package (Application under 10.6.x)
    Drag and drop the icon of a text file on the application's one will do the job.
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    Under 10.6.x,
    go to the General panel of AppleScript Editor’s Preferences dialog box
    and check the “Show Script menu in menu bar” option.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2010/08/19
    --=====
    on run
    set un_fichier to choose file with prompt "Choose e text file…" of type {"public.plain-text"} without invisibles
    my commun(un_fichier)
    end run
    --=====
    on open (sel)
    set un_fichier to item 1 of sel
    tell application "System Events" to set type_ID to type identifier of disk item ("" & un_fichier)
    if type_ID is "public.plain-text" then my commun(un_fichier as alias)
    error "The file “" & un_fichier & "” isn’t a text file !"
    end open
    --=====
    on commun(le_fichier)
    set le_contenu to read le_fichier
    set le_contenu to "azer ertyuio wxcv dfghj
    qszaed dc fghj mlkjhgf nbvcxw
    aqwzsx edcrfv tg byhn aaaaaaa "
    set listedelistes to {}
    set plusgrandelongueur to 0
    set pluspetitelongueur to 999999
    set listelignesbrutes to paragraphs of le_contenu
    repeat with refd_uneligne in listelignesbrutes
    set maybe to contents of refd_uneligne
    set maybe2 to count of maybe
    if maybe2 > plusgrandelongueur then set plusgrandelongueur to maybe2
    if maybe2 < pluspetitelongueur then set pluspetitelongueur to maybe2
    copy my decoupe(maybe, space) to end of listedelistes
    end repeat
    set differencedelongueur to plusgrandelongueur - pluspetitelongueur
    set des_espaces to space
    repeat differencedelongueur times
    set des_espaces to des_espaces & space
    end repeat
    set largeur1 to 0
    repeat with refd_uneligne in listedelistes
    set maybe to length of first item of refd_uneligne
    if maybe > largeur1 then set largeur1 to maybe
    end repeat
    set liste_finale to {}
    repeat with refd_uneligne in listelignesbrutes
    set maybe to contents of refd_uneligne
    set maybe2 to text 1 thru largeur1 of maybe
    repeat while maybe2 ends with space
    set maybe2 to text 1 thru -2 of maybe2
    end repeat
    copy maybe2 to end of liste_finale
    copy text (largeur1 + 2) thru plusgrandelongueur of (maybe & des_espaces) to contents of refd_uneligne
    end repeat
    Enter the bigger loop *)
    set cest_Lafin to false
    repeat
    Deprieve the stored rows of the treated column's items *)
    set flag to 0
    repeat
    set flag to flag + 1
    set flag2 to 0
    repeat with refd_uneligne in listelignesbrutes
    if "" & character flag of contents of refd_uneligne is space then set flag2 to flag2 + 1
    end repeat
    if flag2 < (count of listelignesbrutes) then exit repeat
    end repeat
    repeat with refd_uneligne in listelignesbrutes
    copy text flag thru -1 of contents of refd_uneligne to contents of refd_uneligne
    end repeat
    Prepare the extraction of next column *)
    repeat with refd_uneligne in listelignesbrutes
    copy my decoupe(contents of refd_uneligne, space) to end of listedelistes
    end repeat
    Extract the width of the column to treat *)
    set largeur1 to 0
    repeat with refd_uneligne in listedelistes
    set maybe to length of first item of refd_uneligne
    if maybe > largeur1 then set largeur1 to maybe
    end repeat
    Extract the column's values *)
    repeat with i from 1 to count of listelignesbrutes
    set maybe to contents of item i of listelignesbrutes
    set maybe2 to text 1 thru largeur1 of maybe
    repeat while maybe2 ends with space
    set maybe2 to text 1 thru -2 of maybe2
    end repeat
    copy (contents of item i of liste_finale) & tab & maybe2 to item i of liste_finale
    try
    copy text (largeur1 + 2) thru -1 of maybe to item i of listelignesbrutes
    on error
    set cest_Lafin to true
    end try
    end repeat -- i
    if cest_Lafin then exit repeat
    end repeat -- bigger loop
    set le_contenu to my recolle(liste_finale, return)
    set the clipboard to le_contenu
    set eof of le_fichier to 0
    write le_contenu to le_fichier
    end commun
    --=====
    on decoupe(t, d)
    local oTIDs, l
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to oTIDs
    return l
    end decoupe
    --=====
    on recolle(l, d)
    local oTIDs, t
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to oTIDs
    return t
    end recolle
    --=====
    --[/SCRIPT]
    Yvan KOENIG (VALLAURIS, France) vendredi 20 août 2010 12:44:33

  • Importing Text from a .txt

    Hi everyone,
    First post here, woo!
    Let's say I have 5 pages (each about 4 frames long), and on
    each page I need to pull in distinctively different text. On page
    1, I need the Bible; page 2, Baghavad Gita; page 3, Yoga
    Sutras...etc. Also, when I pull them in, I need to be able to play
    with them. For example, I need to be able to hide each paragraph
    when I click a button.
    I first thought I'd need to import a text file into a text
    box I pre-defined on the stage, but I can't seem to get that to
    override the text of a MovieClip (come on, I'm a rookie!). Then I
    thought I'd just ActionScript a text box into existence with code.
    Only problem is, I need to animate it to disappear when I click a
    button, and re-appear again (which I achieve with just having it
    scroll off the stage - any suggestions on improving this situation
    would also be much appreciated).
    So, my question is: How do I pull in external text files (or
    internal? - if I'm over-complicating things) onto the stage, so
    that I can animate them to do things like disappear, or move, or
    whatever really?
    Am I making sense? All help would be GREATLY appreciated!
    Cheers
    Marc

    To pull in your external data, I would advise using XML (make
    sure to use CDATA with large text blocks). AS3 has a new beautiful
    way to pull and parse XML Data. Just use a URLLoader/URLRequest to
    get the XML data, then use the E4X Parser built in Flash to parse
    the data, here's an example:
    http://pixelfumes.blogspot.com/2007/05/easy-xml-parsing-using-as3-actionscript.html

  • HT5538 What happens if u have two phone numbers and now u are receiving texts from ur self every time u send a text to the other number on ur id?

    I have my boyfriends number (iPhone 4) connected to my account with my iPhone 4S and iPad 2 when he texts me after he updated his phone last night it now sends us both the message sent every time so the conversation is now on two different conversations on the phone.  Please help

    Settings > Messages > Send and Received > Uncheck any number/email that does not belong to the device
    Note: The little blue (>) will give you an option to remove the number/email from the device
    Note: Check this setting on any device(s) using the same Apple ID

  • Export text from pdf to csv or xls / identity-H text

    Hello,
    Is it possible to export text in a pdf to a csv or an excel file (with coresponding page numbers where the text was found)
    For a product we make we need to put all the text of a page into the metadata of the page. Normally we use a ghostscript for this but when customers provide a PDF with identity-H text this won't work most of the time. When this doesn't work we create a postscript of this PDF and recreate a PDF with distiller, quite often after this the ghostscript will recognize the text, but if it doesn't work... then we need to put all the text manually in an excel file and with all the text boxes and lay-out in the PDF this is a quite frustrating task.(especially a few hundred pages)
    The question on top is a sulotion which will work if it is possible because that is failproof but, if someone knows an other solution to the actual problem we experience with identity-H that would be very helpfull too.
    Thanks in advance!

    Here is a visual example of what I am referring to, showing the right-click location and the different options that appear. (The blue selection box is from me selecting and dragging around the question from a non-text area)

  • [Win CS5] Import text from *.txt, analyse and place

    Hello everybody!
    I hope this hasn't been posted before, I've used the search function, but haven't found anything...
    This is my problem:
    I have a *.txt file with vocabulary, organised like this:
    vocable<tab>1. translation
    <tab>2. translation
    vocable<tab>translation
    (vocables and traductions are separated by tabs)
    Example:
    suscipio, is, ere, suscepi, susceptum<tab>(ici) prendre sur soi, entreprendre
    deposco, is, ere, depoposci, /<tab>demander avec instance, exiger, réclamer
    injungo, is, ere, injured, injunctum<tab>1. appliquer dans
    <tab>2. joindre à, relier (tecta injuncta muro)
    <tab>3. infliger (injuriam alicui)
    <tab>4. imposer (servitutem alicui)
    I want to place the vocable on a page in a textframe (4x5 textframes on a page), and the translation on the next page in a textframe, at the position where the vocable is located on the back, if you print the two pages duplex on a sheet (so that if you cut the textframes out, the vocable is on one side, the translation on the back). The problem is that I have no idea how to write a script in JavaScript which analyses the text from the *.txt file, and pastes the vocable and its translation in the rigth textframes. Another problem is, if it's easier to generate the textframes first, and paste the text, or to search the vocable and the translation and then generate the textframe and its content :-S
    It'd be kind if anybody could help me with this or give me a hint!
    Thx a lot!
    Jean-Pierre

    But all white color are not the same…
    If your background is the size of the entire book page that's not a problem. Your picture will simply sit on top of your all white background with the letters at the bottom - no chance of seeing an outlined box around it. If there ever was a discernible difference you certainly wouldn't notice it from one page to another. And anyway, won't full white (100%) register as no ink when the book is printed?
    Again, if you're unsure why not just go for the simplest solution? Do your page design in Photoshop (you're already creating your background) and use the book tool to do the final layout and send it out. Sometimes simple is the best answer!

Maybe you are looking for