A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 40

Thread: loading variables into textbox

  1. #1
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48

    loading variables string into textbox

    in the txtfile
    Code:
    var1="a"
    &var2="b"
    &var3="c"
    &varloaded="ok"   //load variables
    now when a person clicks on certain combox box item (a,b, or c) the string from the variable is placed in a textbox,

    Code:
    loadVariables("myfile.txt");
    if (varloaded = "ok") {
    	trace ("loaded");
    myTxt.text = combo.getSelectedItem().data; };
    the data in the combobox is var1, var2, var3 i need these to load the strings associated with them to the textbox
    this isnt working the way id like it too, it doesnt even trace that theyre loaded...no idea whats wrong..thanks
    Last edited by suprme32; 09-03-2003 at 02:17 AM.
    it makes my head spin..

  2. #2
    shorter than most, but not all findShorty's Avatar
    Join Date
    Apr 2002
    Location
    brisbane
    Posts
    239
    first of all, you don't need the quotes around the variables in your text file, so your textfile would look like this:
    &var1=a
    &var2=b
    &var3=c
    &varloaded=ok

    what you also need to do is load the variables into either a level or into a movieclip. i suggest loading them into a movieclip.
    code:

    this.loadVariables("myfile.txt");


    also, you need to use an onData command with that movieclip to verify when the data is loaded.
    code:

    this.onData = function () {
    if (varloaded=="ok") {
    trace("data loaded");
    // place your data in the combo boxes
    }
    }



    hope this helps

  3. #3
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    ok i got it to load the variables using a diff method then from above, now that they are loaded when i do

    changeHandler

    Code:
    function loadit() {
    		trace(comTV.getSelectedItem(comTV.getValue).data);
            myTxt.text = comTV.getSelectedItem(comTV.getValue).data;
    }
    // that returns the variable name and not the actual string associated with the variable

    why wouldnt it return the string?

    also even tho just the .data value is gettin placed, the first one i click on will stay in the textbox, it wont change when i click on another selection
    Last edited by suprme32; 09-02-2003 at 09:43 PM.
    it makes my head spin..

  4. #4
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    bumpity bump bump
    it makes my head spin..

  5. #5
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    really need some help with this, if im doing it wrong please let me know, if you know its not possible, please let me know either way
    it makes my head spin..

  6. #6
    shorter than most, but not all findShorty's Avatar
    Join Date
    Apr 2002
    Location
    brisbane
    Posts
    239
    Sorry for delay. Very Busy.

    Why have you put comTV.getValue inside the parenthesis? not needed.

    your line should read

    myText.text = comTV.getSelectedItem().data;

  7. #7
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    ive tried it both ways, no result, just shows var1, var2, var3....(the value of the data) doesnt treat data as a variable
    it makes my head spin..

  8. #8
    Professional Air Guitarist Frag's Avatar
    Join Date
    Dec 2002
    Location
    Brain, Body, Clothes, Computer Chair, Room, House, Neighborhood, City, State, Country, Continent, World, Galaxy, Universe, and on?
    Posts
    811
    This board is too competitive...

    Can't we all just get along?

  9. #9
    Professional Air Guitarist Frag's Avatar
    Join Date
    Dec 2002
    Location
    Brain, Body, Clothes, Computer Chair, Room, House, Neighborhood, City, State, Country, Continent, World, Galaxy, Universe, and on?
    Posts
    811
    Sorry, too tired to think of anything funny or witty or smart to say to that

  10. #10
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    attachment...can we please argue in a different topic ur cloggin my mail server..lol ...and making me excited thinking a solution has been found
    Attached Files Attached Files
    Last edited by suprme32; 09-04-2003 at 01:06 AM.
    it makes my head spin..

  11. #11
    Professional Air Guitarist Frag's Avatar
    Join Date
    Dec 2002
    Location
    Brain, Body, Clothes, Computer Chair, Room, House, Neighborhood, City, State, Country, Continent, World, Galaxy, Universe, and on?
    Posts
    811
    Times have changed! We young people are becoming more and more nocturnal (spelled right?).

  12. #12
    shorter than most, but not all findShorty's Avatar
    Join Date
    Apr 2002
    Location
    brisbane
    Posts
    239
    ... imposing your own views is not allways [sic] the ideal or only solution!
    what are you on about?

    From Flash MX Reference
    Usage

    myComboBox.getSelectedItem()

    Parameters

    None.
    i merely pointed out to suprme32 that he'd got his usage wrong oldnewbie. maybe i should have sent him to some far off tutorial site instead of actually trying to help him solve his specific problem.....

  13. #13
    Professional Air Guitarist Frag's Avatar
    Join Date
    Dec 2002
    Location
    Brain, Body, Clothes, Computer Chair, Room, House, Neighborhood, City, State, Country, Continent, World, Galaxy, Universe, and on?
    Posts
    811
    I don't wanna grow up, I don't wanna grow up, I don't wanna wear a tie...
    Last edited by Frag; 09-04-2003 at 01:17 AM.

  14. #14
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    Originally posted by findShorty
    what are you on about?

    From Flash MX Reference


    i merely pointed out to suprme32 that he'd got his usage wrong oldnewbie. maybe i should have sent him to some far off tutorial site instead of actually trying to help him solve his specific problem.....
    that way still worked tho..
    Last edited by suprme32; 09-04-2003 at 01:27 AM.
    it makes my head spin..

  15. #15
    shorter than most, but not all findShorty's Avatar
    Join Date
    Apr 2002
    Location
    brisbane
    Posts
    239
    Kids?
    Don't patronise me old man. You have no idea how old I am, and frankly I couldn't care less whether people think i have an attitude problem. When I have time, i do my best to help people out, without passing the buck onto some tutorial site. The fact is, that the way I do things works.

    And by the way suprme - sorry for that interuption - in answer to your original problem:

    the instance names in your change handler and your combo box did not match. one was ComBo and the other was ComTV.

    i changed them and it works fine.

    however, when you get to the stage when you are loading the vars in, you'll need an event handler to test whether the variables have loaded into importVars.

    so it would be something like:
    code:

    importVars.onLoad = function () {
    //distribute vars to combo box
    };


  16. #16
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    it doesnt work fine tho, cause when you change that (was typo on my part).....click on "test 2" in combo and it says var2 in textbox, it should say "variable 2 loaded"
    it makes my head spin..

  17. #17
    shorter than most, but not all findShorty's Avatar
    Join Date
    Apr 2002
    Location
    brisbane
    Posts
    239
    in the fla you gave me, you haven't distributed any of your data to the combo box. you can't simply write the variables names into the combo box Data values field. at present, var1, var2, and var3 ARE the values you have in the combo box, and thats why these are being displayed.
    you need to add the following function to distribute the data:
    code:

    importVars.onLoad = function () {
    for (var i=0; i<3; i++) {
    comBo.addItem("my label"+i,importVars["var"+(i+1)]);
    }
    }


  18. #18
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    the values do not change when i click on one and then another, always stays on my first choice, also, the combobox values are hardcoded into the combobox, i would rather not load them the way you show, unless its the only way




    MY ULTIMATE GOAL!!

    this will be used as a description for each combo item, the description is loaded to the box, depending on the variable, the descriptions can get pretty long so i would like to load them from a single textfile, i realize its possible to load 1 description per file, i would like to load all descriptions from 1 file, any way to do this, would be extremely helpful thanks
    Last edited by suprme32; 09-04-2003 at 01:58 AM.
    it makes my head spin..

  19. #19
    shorter than most, but not all findShorty's Avatar
    Join Date
    Apr 2002
    Location
    brisbane
    Posts
    239
    sorry i forgot to tell you. you need to remove all the items from the combo box.

    if you are loading variables in, the only way you are going to get it working is by using the addItem method.

    the way you have it at the moment, the data for say, combo box item 1, is "var1", not the value of var1.

  20. #20
    semi-experienced
    Join Date
    Dec 2002
    Location
    CA
    Posts
    48
    still only shows first item clicked in combo
    it makes my head spin..

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