A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F8] Array issues

  1. #1
    Senior Member
    Join Date
    Dec 2005
    Posts
    426

    [F8] Array issues

    I have this code.

    Code:
    var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
    weapon_delay[i]=parseInt(r.result);
    if i trace r.result it will come up with the right value, but when i trace weapon_delay[1] it comes up as undefined.

    there should be 4 values in weapon_delay.

  2. #2
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    what happens if you do this?

    Code:
    var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
    weapon_delay[0]=parseInt(r.result);
    ~calmchess~

  3. #3
    Senior Member
    Join Date
    Dec 2005
    Posts
    426
    nope still undefined

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    what is: r.result? Make sure it's just a number not any extra spaces or anything.
    .

  5. #5
    Senior Member
    Join Date
    Dec 2005
    Posts
    426
    r.result is {4,20,30,3}
    here is a whole chunk of the code im using incase something else is messing it up.
    Code:
    for(i=0;i<fileList.length;i++){
    	file = "data\\weapons\\"+fileList[i];
    	ssDebug.trace(fileList[i]);
    	var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"name", defaultValue:"?"});
    weapon_name=r.result;
    var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
    weapon_delay[i]=parseInt(r.result);
    ssDebug.trace(r.result+"b");
    var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"image", defaultValue:"?"});
    _root.projectile_speed[i]=parseInt(r.result);
    var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"explosion", defaultValue:"?"});
    _root.projectile_explosion[i]=parseInt(r.result);
    var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"damage", defaultValue:"?"});
    _root.projectile_damage[i]=parseInt(r.result);
    var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"amount", defaultValue:"?"});
    _root.projectile_amount[i]=parseInt(r.result);
    var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"random", defaultValue:"?"});
    _root.projectile_random[i]=parseInt(r.result);
    var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"speed", defaultValue:"?"});
    _root.projectile_speed[i]=parseInt(r.result);
    }

  6. #6
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    Instead of this:
    weapon_delay[i]=parseInt(r.result);
    use this:
    weapon_delay=r.result.split(",");
    this will separate all of the numbers in r.result and place them into the array. No loop necessary because it will separate the whole string at once.
    .

  7. #7
    Senior Member
    Join Date
    Dec 2005
    Posts
    426
    but it only loads 1 file at a time.
    so each time the loop is run is run r.result is 4
    2nd time it is 20
    so on.

  8. #8
    Senior Member
    Join Date
    Dec 2005
    Posts
    426
    ok, what i will do is make it a string and do this:
    Code:
    var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
    weapon_delay+=","+parseInt(r.result);
    then split that up.

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