A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: loadvariablesNum dynamic load.txt

  1. #1
    Junior Member
    Join Date
    Oct 2000
    Location
    PTBO, ON, CAN
    Posts
    10

    loadvariablesNum dynamic load.txt

    I have this movies that I am using to collect data from page counters.
    Each counter that I use has the same variable name
    counter[name].txt

    The Question is???

    how do I place the variable [loaded.txt files variable has same name]
    In to a assigned txt area. via changing the var to new name.

    stop();
    loadVariables("count.txt", "[aNumber]");
    //so when the next one come in
    loadVariables("countertwo.txt", "aNumber");
    //so I need the var name to change or all the text areas show the irst value

    //and the var is aNumber , number in the text file

    Now I want to load many diferent count[name].txt files and have the data come in to each its own text area/at eh the same time.
    I think with aray

    how to just switch the variable to a new variable

    Maddalien -peace - not - gunds -
    <M><A><C>

  2. #2
    Flash Addict angiedarrah's Avatar
    Join Date
    Apr 2002
    Location
    Asheville, NC
    Posts
    123
    The name of your text file is irrelevant once Flash opens it and retrieves the variables. Your variables will be stored as they are names within the text files. Example: "folder1/Counter.txt" contains "&variableName=property". So really all you need to be concerned about is the variables within the text files. Tf they are all different, thenyou have no problems. If they are all the same, you could create a Movie clip that opens the text files one at a time and reassigns the value for your variables (that have the same name) to a completely new variable.
    Example: (say the variables within the text file are all named count and all the text files are named counter.txt) You could use:

    NOTE:This code uses loadVariables which must be attached to a MC rather than loadVariablesNum which can be used on the main timeline. You must also have a stop(); action on each frame that this action is used [so it ends up being a MC (loading the variables) within another MC (where the timeline advance for each new variable loaded)].
    Code:
    onClipEvent(enterFrame){
       loadVariables("counter.txt",this);
       _root.count1= count;
       //using root will create a sort of global variable that is 
       //much easier to target then if it were nested within a clip.
    } 
    
    onClipEvent(data){
        //this action will be performed after your variables are finished loading.
        gotoAndPlay(nextFrame);
    }
    Then on the next frame have the same thing, but change count1 to count 2 and so on. Then you will have all your values on the main timeline listed as count1, count2, count 3 and so on. You could easily keep track of them in an array with some slight modifications or use a variable to count for you, I was just trying to keep it simple. Not so sure I did that though, as simple as I can explain. Hope this helps.

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Location
    PTBO, ON, CAN
    Posts
    10
    yea I don't get that..

    Maybee a array thingy.. I look in to that.

    One thing is that I don't have a var name "&name" I guess as flash would like to use.

    but you said that it dose not matter when the var is loaded.

    I tryed that _root. thing I can't get that to work//
    // I will try again

    I do have a MC that allowsw me to go frame by frame to view that data loasing dynamicaly its just thatI want it to display all at the same time..

    what is the easy way to just move and rename a var.

    I think that is usefull in all kinds a places

    i am thinking that the keyword is Duplicate

    "&name"
    <M><A><C>

  4. #4
    Flash Addict angiedarrah's Avatar
    Join Date
    Apr 2002
    Location
    Asheville, NC
    Posts
    123
    Regarding the array: Forget the array, you don't NEED an array, it would just make things more organised and easier to use.

    Regarding _root: The _root.variable is a very simple idea once you understand it. _root simply refers to the main timeline. In flash you can have variables, instances and functions anywhere in your movie. However, to effectivly use any of them you need to be able to TARGET them. _root simply targets variables and such that are located on your main timeline.

    You said:
    One thing is that I don't have a var name "&name" I guess as flash would like to use.

    but you said that it dose not matter when the var is loaded.
    The next paragraph is assuming that your .txt files simply contain values, like "value". If your text files contain "variable=value" rather than "&variable=value", as long as flash understands it that will not matter.

    (From my knowledge of loadVaribles and regaurding what I was reffering to previously:) What does not matter once the variable is loaded is the file name, such as "counter.txt". It DOES matter that there is no variable name in your txt file. If there is no "&name=value" then the information is useless to flash once loaded as it is. To use loadVariables or loadVariablesNum, you need to use "&name=value" or flash will not know what to do with the information and it will be completely useless. I will load the number "999" for example but not have any idea what it is and no way of reffering to it for later use. It will just be a number or a value. it needs to have a variable name that flash can use to refer to the value. There may be a way of using your text files as they are with no variable in them and assigning one to the value after it is loaded, but I am not aware of how to do that or if it is even possible. (I only have experience using txt files formatted specifically for flash that are set up this way with "&variable=value")

    If you load a text file that contains "variable1=property1" then flash understands it as:
    Code:
    var variable1;
    variable1 = "property1"l;
    if you load a text file that contains "999" flash just gets a number, with no variable. Flash understand that as:
    Code:
    999;
    Try typing that into your into actions panel. Flash won't do anything with that number, except forget it when the play head passed the frame where it resides.

    I would recommend you try a more simple arroach to practice using your loadVariables and/or loadVariablesNum. First understand the basics of how they work, then try something more advanced like what you are doing. Start with the basics and work up. If you don't understand how they work simply it will be near impossible for them to work in a more complicated way.

    You should post another thread asking how to handle loading text files with no variable and work form there. First try to just get one to work as a variable and then worry about loading them all. (From what I understand, YES, it will load one file as a value, but not as a variable that can be reffered to and used.)

  5. #5
    Flash Addict angiedarrah's Avatar
    Join Date
    Apr 2002
    Location
    Asheville, NC
    Posts
    123
    what is the easy way to just move and rename a var.
    That is exactly what my first code does.
    Code:
    onClipEvent(enterFrame){
       loadVariables("counter.txt",this);
       _root.count1 = count;
    } 
    
    onClipEvent(data){
        gotoAndPlay(nextFrame);
    }
    Lets assume that your text file contains "&count=999";
    _root.count1= count;
    This line assigns thae value of count(999 in this example)to a NEW variable on the main timeline (thus the _root.Variable name)and it is now MOVED becuase it is no longer in the MC, but on the main timeline. So now the variable count1 located on the main timeline has the value of 999. (This variable can also be refered to as _root.count1 from anywhere within your movie.)

    It is also recommended to create a new layer in your root(or main) movie and have it go through all the frames and simply type in the actions panel:
    Code:
    var count1;
    var count2;
    var count3;
    var count4;
    //do this for as many files as you have
    Then create dynamic text boxes with the value of "counter1", "counter2" and so on (if they are on the main timeline you will not need _root although it will not hust if you use it. If they are within ANY movie clips then you will need ot use _root so Flash knows where the variables are located.)
    This way all your values can be displayed at once.

    Does this make any more sense now?

  6. #6
    Junior Member
    Join Date
    Oct 2000
    Location
    PTBO, ON, CAN
    Posts
    10
    hi again

    I tryed that and in the Dynamic text feild name [count1]all I get is
    count1 in the text area.. from this line.>>_root.count = "count1";

    your most liky right that I should try some thing easyer but that is what lead me here to this question.

    New Question. How do you get the value from the text feild to a new var;?

    I understand
    Mainstage
    var count1;
    var count2;
    and so on.

    Then MC with

    // I noticed that you had a "this" in your code what dose that do?

    onClipEvent (load) {
    loadVariables("countall.txt", "[you had "this" here?]");
    _root.count = "count1";
    }
    onClipEvent (load) {
    nextFrame();
    }

    and at the end the dynamic text feilds with logical name ofthe var used.

    it the load file the name of the var is "hits=000001"

    and if I loadvariablesNum("counter.txt", "hits");

    and the have a dynamic text feild that is name 'hits'
    no problem for one loaded varaible.

    but if two are loaded then hits get replaced with the new var hits in the second file.

    Can you get a value out of a text box and rename that value with a new var ...

    this is wha i have so you can see what I am trying to do. I just want them all at once.
    stats test

    iII keep working with that code you sent to see if I can get that to work

    peace maddalien
    <M><A><C>

  7. #7
    Flash Addict angiedarrah's Avatar
    Join Date
    Apr 2002
    Location
    Asheville, NC
    Posts
    123
    You said:
    I tryed that and in the Dynamic text feild name [count1]all I get is
    count1 in the text area.. from this line.>>_root.count = "count1";
    You have it backwards, it should be:
    _root.count1 = count;
    *and if you put "quotes" around anything, it thinks it is a string, not a variable. (A string is a phrase or any combination of letters like "Hello World!" it can be a value of a variable, but not a variable itself. Never put quotes around a variable.)

    I am still confused about what exactly is in your text files. Please reply and let me know exactly what is in them. Example: "999" or "count=999" or"&count=999"

    I will continue to work with you until you are successful or until I can not solve your problems anymore. However, becuase you seem to be working on a more advanced project than your understanding of Flash at this point, all I ask of you is to learn to use your Flash Help system to help you understand the actionscript language that is required to be used for your purposes here (and hopefully future projects as well).

    Just open your Flash program and hit "F1" or click on "Help" then "Using Flash". Learn to use the system to help you answer simple questions first. Then you can use it to answer larger ones. I personally like to use the "search" feature. So use that to gain a better understanding of "_root", "this" (both of these terms are related to targeting items within your flash movie)"loadVaribales" and"loadVariablesNum".

    I am also very fond of books as well. I love Colin Moock's "Actionscript: the Definative Guide" (for Flash 5 -but also available for MX) and "Flash MX Designer's GActionscript Reference." (for Flash MX)

    I will work on a movie that does exactly what I was reffering to, but if your files do not contian variables like "&count=999" or "count=999" then it will need additional changes or may not work at all. I do not believe in fixing someone's problem for them, but rather in helping them learn. You seem eager and appreciative so I want to continue helping you. To clarify the confusions here, I think it will be easier to just show you it working in a movie. So please return the favor and become familiar with the help system and learn to effectively use "_root", "this", "loadVariablesNum" and"loadVariables".

    Please remember to reply to my first question in this post.

  8. #8
    Flash Addict angiedarrah's Avatar
    Join Date
    Apr 2002
    Location
    Asheville, NC
    Posts
    123
    Sorry, I see now that you said:
    it the load file the name of the var is "hits=000001"

    Ok, this should be fine.
    Will upload a fla as soon as I can.

  9. #9
    Flash Addict angiedarrah's Avatar
    Join Date
    Apr 2002
    Location
    Asheville, NC
    Posts
    123
    I got it working, but I actually found a more simple approach than what I had imagined previously. (I just used multiple MCs and loaded each text file into a different MC using loadVariables _NOT_ loadVariablesNum. They are different.)

    View working file:
    http://www.a1flash.com/flashkit/load...Variables1.swf

    I have also attached a zip file containing the .fla, .swf and three text files. This should be very easy to plug into any existing movie. Just drag the MC containnig the variables into any movie in its own layer that spans throughout the timeline. Also create a layer on your main timeline with the variables ( var hit1; var hit2:...etc) as seen in fla.
    Then you will only need to edit the sources for the txt file within the MCs.

    Hope this fits your needs.
    Attached Files Attached Files

  10. #10
    Junior Member
    Join Date
    Oct 2000
    Location
    PTBO, ON, CAN
    Posts
    10

    the <eof>

    Thx very much angeldarrah

    thatis great stuff.

    Now I see how MainTimeLine {mtl} and the MC work together with that

    THX much appreciation
    that work well Cheers, I guess that I was just wanting it to be easyer yet with a single loadvar on the maintimeline
    but Hey, it work


    page

    till next time

    peace and love
    [neil young]
    <M><A><C>

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center