ActionScript 2.0 :: Creating Arrays With Loadvars?
Jan 20, 2007
I am trying to create an array from data in a text file.The text file data is like so:&track1=Paradise Lake&track2=Somewhere Else&track3=Another Placeetc..What I am trying to do is take all tracks and put them into an array so that i can attachmovies to the stage referencing them. So far if I try a:
Code:
trace[myVars.track1]
for instance, it spits out the correct variable into the output window.
I have a for loop with counter set to the number of items in the arrays, with the idea of inserting data from each array into the fields of the following DiffArray. I am getting Error #1009: Cannot access a property or method of a null object reference and I cant see why.
how to use an array to create a back button for something I've made in Flash. I wish it was as easy as making the back button go to the previous slide, but there are several branching scenarios where that scenario won't exactly work. I purchased a membership to Lynda.com in order to try and learn AS3, but the section they have on arrays in AS3 doesn't come close to teaching me what I need to know for this kind of operation.
I've got four arrays which I want to use to create objects on the stage. The first one is what the Object Class is called. The second one is what I want the instance name to be. The third and fourth relate to the x and y co-ordinates respectively.
The "i" would relate to the parameters for the same object. So, if i = 0, then the Object Class Name would be: 'Background', the instance name would be 'bg', the x position would be '0', and the y position would '0'. What code would I need in the for loop to create this?
I'm currently trying to program a flash game using actionscript 3.0 where users would step on insects. Basically, I added multiple instances of insects movieclip and remove them by using hitTest function. When the mouse_mc. hitTestObject(insect), there were times the insect was not removed.
Here are the errors I encountered: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display:isplayObjectContainer/swapChildren() at SteppingGame/hitTest() Error #1009: Cannot access a property or method of a null object reference. at insectmc/onEnterFrameEvent_SF()
Also, is there anyway I could simply my code like creating multiple arrays of movieclip insectmc? Here's my as3 code: package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.ui.Mouse; import flash.display.Sprite; [Code] .....
One of the moderators, could you've a look at this tutorial: [URL] it doesn't works with me, maybe because I've 2004 so if you change loadVars() into LoadVars() it should work
I'm extremely new to coding in Flash and facing a tight deadline. What I'm trying to accomplish is to generate a hitTestObject for dynamically named instances being pulled out of arrays.[code]
THE CODE ABOVE DOES NOT WORK ,I want to create 10 moveiclips each with unique name, which I can move around or maybe load things into later. At the moment the trace returns 'undefined' so the movieclips aren't even being created.
I am creating a computer game with a save game function which outputs the contents of an array to a shared object, so that users don't loose their place.However, I wish for this to work with multiple users, and realise that to do this I need a new seperate "folder" within the shared object being created for each new users data array.I know it must be something like....
// Define the shared object using a "sublevel" for each users data array... _root.savegame.sublevel = sharedobject.getLocal("savegame"; "/"); // somehow dynamically change "sublevel" to the contents of the var "currentUser" as defined when the user logs in when the game loads up.
OR...
//Define the shared object but using a variable title for the actual SO... _root.savegame = sharedobject.getLocal("savegame_currentUser", "/"); //with that "currentUser" being dynamically substituted for the contents of the var "currentUser" which is defined when the User logs in when the game loads up.
so I have writing a function that returns objects on the stage and puts them into an array. and the function works fine until i call the function on more than one object name, meaning if im in the root class, and I call this function on object1 lets say it will add all the object one's from the stage, but if i call it on object2 it will throw an error, which makes some sense, i guess it means that it is not adding it to a unique array, but im not sure how to do that. would it be a good idea to maybe make a multidimensional array? if that is the case would it be too slow?
I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:
var slideDataArray:Array = new Array(); var slideShowDataArray:Array = new Array(); slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........
I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.
I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.
I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:
var ar1:Array = [1,2,3,4,5,6,7,8,9]; var ar2:Array = ['a','b','c','d','e','f','g','h']; function merge(...multi):Array[code].....
Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.
A little explanation: Im making a random arranging number Array. So instead of using a loop and assigning 0 to first array element, 1 to second, etc.I need to make it totally random but without repeating any numbers. To do that I made a second Array that will have the same number of children to serve as a reference.Each of them will be an Object with a property "num" , wich will be its actual number, and a property "called" wich defaults to false.Like this:
ActionScript Code: for(var i:int=0;i<vQuantity;i++){ ranArray.push( new Object() );
I've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.
correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.The hierarchy I want to create is as follows:
AllBrigades (array of Brigades) Brigade (object) BrigadeUnits (array within Brigade object) Unit (Object to be stored in BrigadeUnits array)
I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:
OK, I am trying to do my first simple user authentication for a test built in Flash. I'm just checking to see if someone with the same name and email exists in the mySQL database and then echoing out entryAllowed=false if they exist.
Code: PHP Code: //query is successful and these vars trace out in flash
I have created a site that calls in text from an external .txt file. The text file is a flat file that is updateable using PHP. What I need is for the Flash site to reflect the current contents of the text file each time it's updated through the PHP interface. I'm using the standard:
I did get it to 'kind of work' at one point, but the output text would flash 'undefined', then show the contents of my text file, then go blank then start that loop over again. Not acceptable.
I am converting a class into AS3 (was AS2). What would be the best way to replace the loadVars ? This is how the code looked like in AS2
ActionScript Code: public function load(csvPath:String): void { // Use the LoadVars class to load in the CSV file as a String var csvLoad:LoadVars = new LoadVars();
I have managed to develop code that will run a php script by passing a variable (obtained from a combobox control) to the MySQL database. Initially this works fine but if I try to repeat the excercise using a different value nothing happens.[code]...
I have read a little bit about loadVars and loadVariables, so I am trying to read and write to a .txt on my server. This is my functions: (only Read works, but Send doesn't)
ActionScript Code: function Load(F, VAR) { var DATA:LoadVars = new LoadVars();[code]...........
There are no errors or something; but the file is the same after Send();
I try to get a variable from php : I have a button with : on (release) { $myLoadVars = new LoadVars(); $myLoadVars_received = new LoadVars(); $myLoadVars.var_to_php = myComboBox.getSelectedItem().label; $myLoadVars.sendAndLoad ( "script.php",$myLoadVars_received); $affich_var = $envelope_received.var_from_php; }
PHP // script.php : <? $result = mysql_query( "select counter from data_base where data1='".$_POST['var_to_php']."'"); $counter = mysql_fetch_row($result); echo ("&var_from_php=$counter[0]"); ?>
My result of all this : nothing happens. no variable is received from php. (The is no request ( from the firewall ) from flash to access the internet). So I think the error is around the sendandload. By the way, the php script works perfectly with loadVariablesNum.
Okay, so ive loaded some data from PHP into a textbox in Flash with loadVariables, but then found out, that loadVariables, havent got a way of checking if everythings loaded. So im gonna use LoadVars instead,This is the old loadVariables code: