SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    external text file

    Code:
    commandsA=Breakfast&commandsB=Lunch&commandsC=Dinner&commandsD=Drinks&a1=Clear&a2=Return TRX&a3=Reprints&a4=Enter
    is there a way to get this vertical?
    like this:

    commandsA=Breakfast&
    commandsB=Lunch&
    commandsC=Dinner&
    ect.

    where Flash would still like it?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a specific reason for this other than readable, I can think of several ways to do that, you using MX or 5?

  3. #3
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MX and yes primarily readability, it's for a client.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay I would make the text file look like
    Code:
    commandsA=Breakfast
    commandsB=Lunch
    commandsC=Dinner
    And the actionscript to load it
    For windows linebreaks
    PHP Code:
    myObj = {};
    myVars = new LoadVars();
    myVars.load("sp.txt");
    myVars.onData = function(raw
    {
     var 
    tmp raw.split("\r\n");
     for(var 
    i=0;i<tmp.length;i++) 
     {
      var 
    tmp2 tmp[i].split("=");
      
    myObj[tmp2[0]] = tmp2[1];
     }

    And for unix linebreaks

    PHP Code:
    myObj = {};
    myVars = new LoadVars();
    myVars.load("sp.txt");
    myVars.onData = function(raw
    {
     var 
    tmp raw.split("\n");
     for(var 
    i=0;i<tmp.length;i++) 
     {
      var 
    tmp2 tmp[i].split("=");
      
    myObj[tmp2[0]] = tmp2[1];
     }


  5. #5
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    trying to implement the Winders version, but no luck

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it just me or is everyone having problems replying with anything but the quick reply box. Anyways, it works fine for me I tested it a couple of times. I was trying to attach a zip file, but you'll have to dl it.
    http://www.irq11.com/~louie/mx/sp.zip

  7. #7
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what's up with mine then?
    http://www.plasmapages.com/keys.zip

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is really interesting, something is keeping the loadVars object from working in yours. I mean the same exact code works in a blank fla, not sure why it doesn't work in yours. Its even as if your movie has somehow gotten corrupted. If you pull all of the stuff except the actionscript layer out of the movie it still doesn't run. I mean the code is valid, its something about your fla.

  9. #9
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, freddy, I got a chance to look at it and you are correct, must have been a corrupted .fla cause I moved everything over to a new one and it appears to import it all in, at least when I do a trace it does. But it doesn't load the text into my text holders? How come?

  10. #10
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But it doesn't load the text into my text holders? How come?
    Does that mean you have some dynamic text fields with variable names attached to them? So you are looking to populate them with data from the text file?

    Flash MX uses instance names for text fields in keeping with the new OOP model. variable names are still there IMO for backward compatibility. You should really now be using actionscript to assign a value to the text property of the text field instances. In order fr the below to work, your text fields need instance names not variable names.


    ie.
    Code:
    myVars = new LoadVars();
    myVars.load("sp.txt" );
    myVars.onData = function(raw) 
    {
    var tmp = raw.split("\n" );
    for(var i=0;i<tmp.length;i++) 
    {
    var tmp2 = tmp[i].split("=" );
    this[tmp2[0]].text = tmp2[1];
    }
    }

  11. #11
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, I can't get it...
    some of this code I don't get....
    here's what I got
    and I did change some from vars to instance names.

    Code:
     
    myVars = new LoadVars();
    myVars.load("keys.txt");
    myVars.onData = function(raw) 
    {
    var tmp = raw.split("\r\n");
    for(var i=0;i<tmp.length;i++) 
    {
    var tmp2 = tmp[i].split("=");
    this[tmp2[0]].text = tmp2[1];					//I don't really get this line
    var myObj = this[tmp2[0]].text = tmp2[1]; 
    }
     traceVars();
    }
    function traceVars()								// my trace is wrong
    {
     for(x in myObj)
     {
      trace (x + " = " + myObj[x]); 
     }
    }

  12. #12
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah the trace function won't work anymore and was only in there to do some debugging. Everything in Flash MX is basically an object. Including text fields. They have properties, including textColor, text, textFont, autoSize, etc..........

    this[tmp2[0]].text = tmp2[1];

    This say find the object named in tmp2[0] which should be the instance name of the text field and coincidentally the variable name from the left side of the = sign in the text file. It says find it and assign the value from the right side of the = sign to its text property. Wanna resend me the fla, and I can show you what I mean.

  13. #13
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks man, I owe ya....

    http://www.plasmapages.com/keys.zip

  14. #14
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You never changed the var names to instance names for most of them. Anyhow, changing this to _root fixed it. See attached.
    Attached Files Attached Files

  15. #15
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed two of them to instance names, figured I would change the rest when the 2 worked

  16. #16
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks man, you get my vote for Advisor of the month

  17. #17
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Except I am not an advisor

  18. #18
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still vote for you!!!!!
    freddy is da man!!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •