ActionScript 3.0 :: Store Large Numbers Of Values (For RPG)?
May 17, 2011
I have plans to make an RPG that is similar to those on the SNES as far as movement goes- you walk one tile in a direction at a time and if the tile that you are trying to move to has been marked as one that can't be walked on, it stops the character from going there. That means that conventional collision wouldn't quite cut it.
So I decided that I would make it to where every tile will have a specific value (one to say that there is no collision, another to say there is, etc.), and every object will have an X and Y value that changes in relation to the character (because there is scrolling in this project).
The thing is, there will be a lot of objects, and there will be a lot of tiles; this will quickly become an unimaginably huge project if I just go ahead and throw objects in.
So, what would be the most efficient way of storing these values? I was thinking of storing it in an XML file or a class, but I haven't really done it before, so I want to get a second opinion before I try and do so.
I am trying to convert a string having numbers to an integer.
//15 9's are there var str:String="999999999999999" var res:Number = new Number(str);
But it is not able to convert correctly as the the var res now has the value 100000000000000000. I know that the number has 52 bits of memory, then why is it not able to do the conversion?
I am working on a maths game which involves generating some large numbers in AS3. When I pass these numbers into a textbox they appear as e.g. 300000, I would like them to appear as 300,000.Is it possible to format a text box to do this?
I'm trying to get the 255 smallest numbers from an array made up of all the alpha values in a given BitmapData, and storing these numbers in the Alpha array for paletteMap().We all know how to get the smallest/highest number from an array, or to delete repeating numbers or even to average numbers inside an array. I've been tweaking for 2 days with these possibilities but unfortunately I can't find anything satisfactory.
I am using a Dictionary where the keys are Number objects, but I run into unexpected problems if the keys are large integers.
Here is some example code that inserts two key-value pairs in a Dictionary, one with a small key and one with a large one:
var dictionary:Dictionary = new Dictionary(); var smallNumberKey:Number = 1; dictionary[smallNumberKey] = "some value";
[Code].....
None of the keys seems to be stored as a Number. Why is that? The first one is stored as an int, which can be converted to a Number. The second one however seems to be stored as a String, which makes no sense to me. What is going on here?
What to use when 32 bit ints or even 53 bit Numbers arent large enough by far? Im thinking of just using a 256 bit array but theres prolly a better way.
How do I find the digit sum of a floating point number?* (Eg Math.pow(10,100)). The correct answer would be 1. I have tried writing two functions, function A does not work for floating point numbers due to it converting numbers to strings, function B does not work for Math.pow(10,100) and other floating point numbers).
Specially: (1 with X zeros) % 10 = not 0, according to flash.
*Alternatively, what method can I use that gives me the last digit of a floating point number, and works for 1 with some number of zeros?
My functions:
private function getDSum(input:Number):Number { var res:Number = 0; for(var i = 0; i < input.toString().length+1; i++){
I was wondering if anyone here had any advice on rendering large numbers of identicalanimated instances. The first step we undertook was to separate out the parts of the instance which are static and render flag them cache as bitmap. However I was wondering if there was a way of rendering the same object multiple times without the player having to recalculate the animations separately for each etc?
Now i have one more doubt in Array.. i want to store some values into an Array from a external txt file.. I want to draw a line graph between two variable(X) and (Y) but i want to read that variable values from a external file.. I try use loadVars() class, but in that i have to assign a varable name to each and every value.. but i want to create a generalised class that will store any number of data into an array..
I am creating a card game application in that dynamic movieclips created on stage and inside those movieclips different cards can drop, which have some values.
If one movieclip contains one card and another movieclip contained two cards and all the other movieclips 3rd,4th,5th.. etc contains some cards then, if i want to go back and want to drop another card at the top of the old one, than how i can do this, because when i go back and drop a new card inside movieclip than it replaces the old one. i don't want to create a new array for each movieclip.
I'm trying to use associative arrays to store my variables but am looking for a solution to change the value of array1[i] to array2[i]. Since it's an associative array, the only way I know how to loop through these kinds of arrays is by the following: Code: for(var i in array1) { trace(array1[i]; }
What I would do when using indexed arrays to change the value of array1[i] to array2[i] would be something like this: Code: for(i=0; i<array1.length; i++) { array1[i] = array2[i]; }
However, I can't see any way you can do this with associative arrays because they do not have a numbered index such that in a loop you could say array1[i] = array2[i] . So I'm looking for a way to do this with associative arrays.
I've been making arrays from numbers produced by the Collatz conjecture. But when the number where we start calculating exceeds over 1x10^16 program can't do any more calculations. It loses it's capability to handle odd numbers. Heres a part of my code that makes calculations:
ActionScript Code: var a:Number; var result:Array = new Array(); var count:int = 0; function calculate(e:TimerEvent):void{ [Code] .....
I need to load anywhere from 100 - 100,000 lines of data. Currently I am reading the data letter by letter which is taking Flash a god awful long time to load it.
Code: ///looop length of file for (h=0; h<GWords.length; h++) { ///Slice each part of the Gcode curr_word = GWords.slice(h, Number(h+1));
[Code]....
Example of how I bring it into the datagrid:
Code: file_parsed.addItem({G:G_Value, F:F_Value, Y:Y_Value, X:X_Value, C:Comment_value}); The file is vector values that I take and draw it out after it is loaded.
Is there a better way to grab the a value between Letters to make things happen quicker?
How do I add array values that are numbers when loaded dynamically via sql?Example script doesn't calculate. Instead it just adds as though the elements of ycor array are string based. So ycor[0] = 2 and ycor[1] = 3 added equals 23 not 5. Of course these elements are being dynamically set via mysql db that generates a xml table. I've left out file locations and passwords for obvious reasons. Why are the elements being treated as strings?
Code: var theXML:XML = new XML(); theXML.ignoreWhite = true;[code].....
Assume you have a variety of number or int based variables that you want to be initialized to some default value. But using 0 could be problematic because 0 is meaningful and could have side affects. I have been working in Actionscript lately and have a variety of value objects with optional parameters so for most variables I set null but for numbers or ints I can't use null. An example:
package com.website.app.model.vo { public class MyValueObject { public function MyValueObject ( _id:String=null, _amount:Number=0, [Code] .....
The difficulty is that using 0 in the above code might be problematic if the value is not ever changed from its initial value. It is easy to detect if a variable has a null value. But detecting 0 may not be so easy because 0 might be a legitimate value. I want to set a default value to make the parameter optional but I also want to later detect in my code if the value was changed from its default without hard to debug side affects. I suppose I could use something like -1 for a value. I suppose it depends on the nature of the variable and the data.
How can I adjust flash so it values can only be whole numbers for dimensions and positions? For some reason flash likes to adjust the numbers I enter in the properties flash changes the number slightly. i.e i set the width to 500 and it'll adjust it to 500.05 or 499.05.
I have a problem with SharedObject. I created SharedObject using AS2.0 it's working fine.... my question is can it possible to store the variable values in an .txt file where the flash file is saved... basically the SharedObject will store the vallues in localdrive with file extention. not only using SharedObject if any other way to store the vaules in .txt file will be helpfull for me... my requirement is to store the the position of the swf file and when the time it reopen, it should start from previous position.
I want to generate a variable number of random numbers less than 16 with no duplicate numbers
Ive posted the fla, and what i'm doing is generating a random number and putting it into an array then using a for loop to cycle through the array for each new random number to check if its already there. if it is, then i want to regenerate that number.
if you test the fla you'll see that all i get in my array is some lovely zero's and i sort of know why this is, but don't know how to stop it.
create a function that picks out X amount of numbers from a set of numbers? So if X=3, then i need this function to pick out 3 different numbers from say a set of numbers (1, 2, 3, 4, 5, 6, 7, 8) and then stored it into X number of variables.
In saying that, X will only =2, and =5. So in the first instance, i'll need 2 random numbers from the set above that are not the same numbers, and second instance 5 random numbers from the set above (also no repeats of numbers). Then i need to be able to store those 2 or 5 different random numbers from the set into variables to call them with other functions.