dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Loadvars Problem

  1. #1

    Loadvars Problem

    Hi everyone!!!

    I've this problem: I'm loading some vars with the LoadVars object in the following format provided by a asp doc:

    Response.write "total=3&txt1=bla1&txt2=bla2&txt3=bla3&title1=tibl a1&title2=tibla2&title3=tibla3"

    When I require the vars in Flash it works only when I got them one by one.

    I want to put them in Array form. So how do I do this?
    I'm doing the folling code:

    code for load ASP
    ...
    end code

    //ONLOAD FUNCTION FOR LOADVAR
    function init(ok){
    arTxt = new Array();
    arTitle = new Array();

    if(ok){
    total = l.total; //loadvar variable <-- OK
    for(i = 0; i < total; i++){
    arTxt[i] = eval(l.txt + i); //GOT txt1, txt2 and so on
    arTitle[2] = eval(l.title + i); //THE SAME
    }
    }else
    trace('FILE NOT LOADED.')
    }

    PS.: I tried to change eval(l.title + i) for this[l.title + i], and it doesn't work too.

    Thanx you guys...

  2. #2
    The world goes - hm.. TheCaramella's Avatar
    Join Date
    Dec 2001
    Location
    Second door on the right, next to the ice bear
    Posts
    642
    I don't really know if this is your problem, but you need an "&" in front of every variable name. The first one you show here, is missing that. That could solve the problem, if it's not just that you didn't copy it right here...

  3. #3
    I don't think that's the problem... I can get all variables, but one by one... Imagine if I have to get a hundred of them... no way. And the process its dynamic too.

  4. #4
    Originally posted by TheCaramella
    I don't really know if this is your problem, but you need an "&" in front of every variable name. The first one you show here, is missing that. That could solve the problem, if it's not just that you didn't copy it right here...


    SOME OTHER IDEA? PLS.

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Location
    Manchester, UK
    Posts
    454
    I've done some asp into flash and I notice your Response.Writeline is like this;

    Response.write "total=3&txt1=bla1&txt2=bla2&txt3=bla3&title1=tibl a1&title2=tibla2&title3=tibla3"

    I had to alter my ASP code to this to get it to work;

    Response.write ("total=3&txt1=bla1&txt2=bla2&txt3=bla3&title1=tib la1&title2=tibla2&title3=tibla3")

    See if it makes a difference with the added parenthesis marks,

    Jon 8o)
    P.S.
    Wouldn't life be easy if Keyboards had a "Make It So" button?
    It could sit next to the "Any" key!!

  6. #6
    Someone else?
    antz.digital.media
    www.antz.com.br

  7. #7
    Senior Member
    Join Date
    Sep 2000
    Location
    Pittsburgh
    Posts
    252
    hi,

    from moocks asdg: "eval converts a string to an operator"

    maybe try something like:

    PHP Code:
    total this.total;
        for(
    i=0;i<total;i++){
            
    arTxt.push(this["txt"+i]);
            
    arTitle.push(this["title"+i]);
        } 
    also in your for loop var i starts at 0 and the variables you are looping through from the loadVars object start at 1 so you'll need to change your data to read something like...

    total=3&txt0=bla0&txt1=bla1&txt2=bla2&title0=tibla 0&title1=tibla1&title2=tibla2

    where txt starts with txt0 as opposed to txt1.

    i recreated this using a text file and loaded in the above and got the results i think your looking for, should be very similar in scope. included the .fla and .txt file.

    Hope this helps some,
    Dunc

    sorry about the php tag, it kept cutting off the for loop..
    Attached Files Attached Files
    Last edited by Dunc; 12-21-2002 at 06:02 AM.

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