ActionScript 3.0 :: Splice() With Regards To Arrays?
Jan 7, 2010I have been reading a bunch of things to try to understand it but I am currently having some intelligentcy difficulties...
Note: splice() with regards to arrays
I have been reading a bunch of things to try to understand it but I am currently having some intelligentcy difficulties...
Note: splice() with regards to arrays
where am I wrong trying to remove non integers ?
vergelijk = [undefined, NaN, 1.076, 0.175, more Numbers..]
clean = function () {
for (c=0; c<vergelijk.length; c++) {[code].........
If I have an array
[Code]....
Then secondPosition is them temp[5] instead of temp[6]...since one has been removed from the array. I have been writing:
temp.splice(firstPosition,1);
temp.splice(secondPosition-1,1);
I don't think this is right...especially if secondPosition is at the beginning of the the "temp" array (i.e. temp[0]). Is there a way to remove two items at once from an array, if they are not side-by-side??
I'm working on an application for a company that wants to create a service for their users. This company currently offers videos that are around 1.5 hours in length, and the service they want to integrate is the ability for the user to 'record' clips of this larger video to create, essentially, a highlight reel. The end result of this service would be a 3 minute video of the user's favorite parts of a huge 1.5 hour long video. Make sense?
For the sake of simplicity in asking my question, imagine the user interaction to be very basic. The user watches the video, he/she can press 'record' to record a clip of the master video. Now... I'm already aware of FLVslicer by Thibault at ByteArray, but I've thought surely there is some other approach to recording / splicing / merging FLV clips than just this guy's framework.
And so finally, my question is: do any of you have insight as to how I might investigate the best way to create this functionality aside from using FLVslicer?
From what I know the whole idea behind having collection classes is introduce extra wrapper methods which will be handy for developers.
Then why does ArrayCollection in Flex not seem to have some methods that array has.
ArrayCollection does not have a copy, concat, join or splice methods which return a new array so we need to do the copy manually?
Currently my code is this[code]...
What I am trying to do is splice the array at the right time in my code so it will disappear from my array- and the affect would be the returnRandom() function won't return that same item ever again. [url]...
Is it me or the indexs in the array are not valid after using splice?
Code:
var arr:Array=new Array(3);
arr[0]=porsh;//car objects..not implemented here just for exemple
[code]....
i am loading in and xml file based on the structure below...
[Code]...
So what i am trying to do is to Splice the array into 2 parts, all the question ID's that are A and all that are B for for example are placed into 2 new array's like so:
[Code]...
but i am having problems with the code below trying to splice them and seperate them,
[Code]...
I am working on a basic game in order to practice my AS3 coding skills. The point I am at is that when my enemies (Falling vertically down) touch the bottom of the stage I want to make all enemies in all of my arrays be removed. Now, the code below works perfect for that description of what I want, but it does not remove everything at the same time. Instead it does not remove all of them at the same time, and it's very noticable. As in there is about a 3-4 second gap between when the first dissapears and when the last does.
So will I need to completely optimize my entire project, or is that any way I can do this process that is more efficient? Also what are your thought on just changing all of the enemies y coordinates to -100 or something at first, and then removing them while they are off the stage?
[code]...
have an array that's loosely packed - is there a way to splice (or otherwise cut out) an object from the array?
View 1 RepliesI'm trying to remove items from an array but its not working like its supposed to.Here is my code:
for(var i:uint = 0;i<OrderModel.getInstance().orders.length; i++){
if (OrderModel.getInstance().orders[i].time == hour){
OrderModel.getInstance().orders.splice(i, 1);[code]....
it deletes all the items but 1. I allways have one item left wich should be deleted but it isnt.
i am trying to splice a string between line breaks.
I have text called in using load vars and a text file. The text file called in has a few lines:
line one text
line two text
line three text
I would like to be able to splice that string so that i can create a string just using the second line of text.
I am trying to remove an element from an array by using splice like:
Code:
myArray[1].splice(2,1);
This works & finds the element I am looking for but it doesn't really remove the element but it will just insert a blank object instead. Am I doing something wrong here. How would I "really" remove the element, meaning that the Array would become shorter?
I have a video and I want to crop part of it and have it play somewhere else on the screen.
Is there a way to do this, possibly by overriding the draw function of flash.media.Video?
i get the above error when I try to use splice on this code:[code]I'm not that great at actionscript, do I have to import something for it to work?
View 3 Repliesis array.splice equal to displaycontainer.removechild?
View 1 RepliesI have an unordered ever-changing array that looks something like this:
12,23,1,4,11
I just want to basically tell the code to remove a specific item, let's say "23". But since the array is constantly changing length, I can't use splice.I also can't have any gaps, such as "12,,1,4,11". It must return "12,1,4,11".And on a related note, can I then check if this array has the same content of numbers as another array (and do I have to put them both in numeric order before it can perform the check, or doesn't it matter that they're not in the same order, as long as they have the same contents)?
I am trying to replace an Object inside my nested array (colArray) by using splice, the object acts as my player and will need to maneuver around the Array it's in. The Problem is splice doesn't appear to be showing anything in return, it comes up with an error saying: Cannot access a property or method of a null object reference.What am i doing wrong ? And how would i go with moving my playerObject around the array?
var gridContainerMC:MovieClip = new MovieClip();
var gridSize:Array = [col,row]; //Rows, Columns
var gridArray:Array = new Array();
var col:Number = 44;
[code]....
I want to crop a video and have part of it play somewhere else. Is it possible to do this, possibly by extending Video or MovieClip and changing how it draws?
View 2 RepliesI have an array with many values pushed into it (happen to be names of objects). I am using a for loop to check all of the objects (by index number) for collisions, etc. Periodically, depending on a condition, I want to remove the currently checked object's name from the array list. I noticed that there is a problem if I immediately splice the checked name from the list. Namely, the list gets shorter, which is what I want, but not until I'm done checking all objects. Is it a good idea to solve the issue by incrementing i-- after the splice? I do this so that the object that used to be next in the list doesn't get skipped.It seems to work very well but I want to know if this is a lame/problematic solution and if there are any better ways of dealing with it
for (i=0;i<myarray.length;i++){
var ob=myarray[i]
//any old condition
[code].....
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.
[Code]....
so my array is longer but u get the point. i want it to whenever i click on any letter, cause they are all on buttons, the one i clicked dissapears. i dont know how to work splice with the "i" variable,
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.
View 5 RepliesI have a drag and drop game. You listen to a sound for exampl "bread" You proceed to drag that mc to a box. If it is the right object I want to remove that mc and splice the array so it doesn't choose that object anymore. However I have notices two things.
When I splice(0) a specific element - then nothing works. When I splice the cuurent indexed element ie: the last element to get right - it doesn't actually remove it from the array. I have highlighted the key code parts.
[Code]....
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() );
[code].......
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.
View 7 Repliescorrect 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:
AllBrigades [0] [2].push (MyUnit);
But when I trace this I just get undefined.
I've just upgraded to CS4 from CS3, and the AS3 project I'm working on which was compiling perfectly well in CS3, is now failing to compile because of a variety of errors.I can solve some of them by casting:
ActionScript Code:
// before
if(clip.stage != null)
// after
if(DisplayObject(clip).stage != null)
But I'm failing to solve them on errors regarding Arrays:
ActionScript Code:
// measurements is an array in both cases
measurements = measurements.splice(index, 1);
// 1180: Call to a possibly undefined method splice.
for(var i:int = 0; i < measurements.length; i++)
// 1202: Access of undefined property length in package measurements.
I'm surprised than a fresh install is behaving like this. Is there some setting somewhere I've not enabled?I set the flex sdk path to the same one that I'm using in Flash Develop, but no luck.
if i have A:Array [1,4,7] and B:Array [5,3,9], how do i turn it into: C:Array [1,4,7,5,3,9]?I've checked the Array class in help ofcourse, but concat(rest ...) can only take in paramaters directly, not an array. is this possible or do i have to do it manually?
View 3 Replies