This is probably something really trivial, but I do have a huge problem with this script at the moment.
It's for an RPG modification to my website, and the flash file is a battle system I'm making for it (the current one is really untidy and keeps having to refresh the page every time someone does something).
Now, when the frame loads up, all the *text*.textholder.text fields are set to "undefined". Meaning that there's probably something wrong with the array. So this part would seem to be the culprit:
Am I setting it up right? Could someone please give me some advice on this.
Oh, and the file to load the variables from, "getflashvars.php" is working fine and returns the following:
(there are no newlines in there, it just looks that way because the line is too long to fit)
Any ideas would be great. Thanks.
| Code: |
| // Can't have it going on and on whilst choosing armour...
stop(); // Load up some variables from the file var allvars = new LoadVars(); allvars.load("getflashvars.php?uid=37"); // Turn them into separate global vars for easy access _global.armour = allvars.armour; _global.helmet = allvars.helmet; _global.shield = allvars.shield; _global.pluses = allvars.pluses; _global.plhp = allvars.plhp; _global.plhpmax = allvars.plhpmax; _global.plmp = allvars.plmp; _global.plmpmax = allvars.plmpmax; _global.plstatus = allvars.plstatus; _global.platt = allvars.platt; _global.pldef = allvars.pldef; _global.plevel = allvars.plevel; _global.plclass = allvars.plclass; _global.plpic = allvars.plpic; // Ok, now we've globalised it all, let's load up the armour and stuff for this frame // Grab the armour data into an array var armour_array:Array = _global.armour.split("ß"); var helmet_array:Array = _global.helmet.split("ß"); var shield_array:Array = _global.shield.split("ß"); // Set the current top item to be the first (0) var currArm:Number = 0; var currHel:Number = 0; var currShi:Number = 0; // Get the total number of each armour type var totalArm:Number = armour_array.length; var totalHel:Number = helmet_array.length; var totalShi:Number = shield_array.length; // Bung the text in the right places // Armour armtext1.textholder.text = armour_array[0]; armtext2.textholder.text = armour_array[1]; armtext3.textholder.text = armour_array[2]; armtext4.textholder.text = armour_array[3]; armtext5.textholder.text = armour_array[4]; armtext6.textholder.text = armour_array[5]; armtext7.textholder.text = armour_array[6]; // Helmets heltext1.textholder.text = helmet_array[0]; heltext2.textholder.text = helmet_array[1]; heltext3.textholder.text = helmet_array[2]; heltext4.textholder.text = helmet_array[3]; heltext5.textholder.text = helmet_array[4]; heltext6.textholder.text = helmet_array[5]; heltext7.textholder.text = helmet_array[6]; // Shields shitext1.textholder.text = shield_array[0]; shitext2.textholder.text = shield_array[1]; shitext3.textholder.text = shield_array[2]; shitext4.textholder.text = shield_array[3]; shitext5.textholder.text = shield_array[4]; shitext6.textholder.text = shield_array[5]; shitext7.textholder.text = shield_array[6]; // functions for the Next buttons function armnextitem(eventObj:Object) { if ((currArm+6)<totalArm) { currArm++; armtext1.textholder.text = armour_array[currArm]; armtext2.textholder.text = armour_array[(currArm+1)]; armtext3.textholder.text = armour_array[(currArm+2)]; armtext4.textholder.text = armour_array[(currArm+3)]; armtext5.textholder.text = armour_array[(currArm+4)]; armtext6.textholder.text = armour_array[(currArm+5)]; armtext7.textholder.text = armour_array[(currArm+6)]; } } function helnextitem(eventObj:Object) { if ((currHel+6)<totalHel) { currHel++; heltext1.textholder.text = helmet_array[currHel]; heltext2.textholder.text = helmet_array[(currHel+1)]; heltext3.textholder.text = helmet_array[(currHel+2)]; heltext4.textholder.text = helmet_array[(currHel+3)]; heltext5.textholder.text = helmet_array[(currHel+4)]; heltext6.textholder.text = helmet_array[(currHel+5)]; heltext7.textholder.text = helmet_array[(currHel+6)]; } } function shinextitem(eventObj:Object) { if ((currShi+6)<totalShi) { currShi++; shitext1.textholder.text = shield_array[currShi]; shitext2.textholder.text = shield_array[(currShi+1)]; shitext3.textholder.text = shield_array[(currShi+2)]; shitext4.textholder.text = shield_array[(currShi+3)]; shitext5.textholder.text = shield_array[(currShi+4)]; shitext6.textholder.text = shield_array[(currShi+5)]; shitext7.textholder.text = shield_array[(currShi+6)]; } } // functions for the Previous buttons function armprevitem(eventObj:Object) { if ((currArm)>0) { currArm = currArm-1; armtext1.textholder.text = armour_array[currArm]; armtext2.textholder.text = armour_array[(currArm+1)]; armtext3.textholder.text = armour_array[(currArm+2)]; armtext4.textholder.text = armour_array[(currArm+3)]; armtext5.textholder.text = armour_array[(currArm+4)]; armtext6.textholder.text = armour_array[(currArm+5)]; armtext7.textholder.text = armour_array[(currArm+6)]; } } function helprevitem(eventObj:Object) { if ((currHel)>0) { currHel = currHel-1; heltext1.textholder.text = helmet_array[currHel]; heltext2.textholder.text = helmet_array[(currHel+1)]; heltext3.textholder.text = helmet_array[(currHel+2)]; heltext4.textholder.text = helmet_array[(currHel+3)]; heltext5.textholder.text = helmet_array[(currHel+4)]; heltext6.textholder.text = helmet_array[(currHel+5)]; heltext7.textholder.text = helmet_array[(currHel+6)]; } } function shiprevitem(eventObj:Object) { if ((currShi)>0) { currShi = currShi-1; shitext1.textholder.text = shield_array[currShi]; shitext2.textholder.text = shield_array[(currShi+1)]; shitext3.textholder.text = shield_array[(currShi+2)]; shitext4.textholder.text = shield_array[(currShi+3)]; shitext5.textholder.text = shield_array[(currShi+4)]; shitext6.textholder.text = shield_array[(currShi+5)]; shitext7.textholder.text = shield_array[(currShi+6)]; } } // add the event listener for the buttons armprev.addEventListener("click", armprevitem); armnext.addEventListener("click", armnextitem); helprev.addEventListener("click", helprevitem); helnext.addEventListener("click", helnextitem); shiprev.addEventListener("click", shiprevitem); shinext.addEventListener("click", shinextitem); |
It's for an RPG modification to my website, and the flash file is a battle system I'm making for it (the current one is really untidy and keeps having to refresh the page every time someone does something).
Now, when the frame loads up, all the *text*.textholder.text fields are set to "undefined". Meaning that there's probably something wrong with the array. So this part would seem to be the culprit:
| Code: |
| // Load up some variables from the file
var allvars = new LoadVars(); allvars.load("getflashvars.php?uid=37"); // Turn them into separate global vars for easy access _global.armour = allvars.armour; _global.helmet = allvars.helmet; _global.shield = allvars.shield; _global.pluses = allvars.pluses; _global.plhp = allvars.plhp; _global.plhpmax = allvars.plhpmax; _global.plmp = allvars.plmp; _global.plmpmax = allvars.plmpmax; _global.plstatus = allvars.plstatus; _global.platt = allvars.platt; _global.pldef = allvars.pldef; _global.plevel = allvars.plevel; _global.plclass = allvars.plclass; _global.plpic = allvars.plpic; // Ok, now we've globalised it all, let's load up the armour and stuff for this frame // Grab the armour data into an array var armour_array:Array = _global.armour.split("ß"); var helmet_array:Array = _global.helmet.split("ß"); var shield_array:Array = _global.shield.split("ß"); |
Am I setting it up right? Could someone please give me some advice on this.
Oh, and the file to load the variables from, "getflashvars.php" is working fine and returns the following:
| Code: |
| armor=Studded Leather Armourß&helmet=Metal Capß&shield=Bucklerß&pluses=&plhp=13&plhpmax=14&plmp=8&plmpmax=8&plstatus=0&platt=14&pldef=11&plevel=3&plclass=Journeyman&plpic=../../shop/uses/arena/arena_player_Journeyman |
(there are no newlines in there, it just looks that way because the line is too long to fit)
Any ideas would be great. Thanks.
