A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: need help on loading vars from txt file

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    79

    need help on loading vars from txt file

    hi
    is there any way i can make a var in a txt file such as a=1 and then get flash to use it
    i need this for a website, i've tried and can't get it to work
    thanks

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    use the LoadVars object
    PHP Code:
    lv = new LoadVars();
    lv.load("test.txt"); // in txt file - &a=1&

    lv.onLoad = function(){
    str lv.atrace(str+"  "+typeof str); // string - rec'd vars are strings
    num parseInt(lv.a); trace(num+"  "+typeof num); // number

    hth

  3. #3
    Member
    Join Date
    Oct 2006
    Posts
    79
    thanks for the post but i don't understand
    ive tried using :

    if (a==1) {

    }

    and it won't work
    ive made a gallery and the idea is if i put a=1 the gallery should load 1 pic
    if a=2 load 2 pic and so on.
    what should i do
    thanks

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    lv.onLoad = function(){
    a = parseInt(lv.a);
    if(a==1){
    // your code
    }
    }

  5. #5
    Member
    Join Date
    Oct 2006
    Posts
    79
    thank you so much, it works perfectly
    it's because i wasn't putting my if within the onload function

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