I 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)?
How do I remove an items from a data bound array? My code follows. for(var i = 0; i < listBox.selectedIndices.length; i++) { var toRemove = listFiles.selectedIndices[i]; dataArray.splice(toRemove, 1);
Here is my swf. The Add Photos works except when you remove items. [URL] Add 3 photos different. Remove 2nd photo. Add a different photo. SWF adds the 2nd photo to the end.
Here is my code private function OnSelectFileRefList(e:Event):void { Alert.show('addstart:' + arrayQueue.length); for each (var f:FileReference in fileRefList.fileList) { var lid:ListItemData = new ListItemData(); lid.fileRef = f; arrayQueue[arrayQueue.length]=lid; [Code] .....
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 have an arrayCollection with the following structure:
[Code]...
the AC is defined as follows:[Bindable] private var projectErrorsAC:ArrayCollection = new ArrayCollection;
I'm using this AC in a repeater to display each error. After each error is shown, I've placed an "Accept" and "Deny" button. Once the user clicks either one of these buttons, I'd like to call a function that removes the particular error from the AC. Here's what I have so far:
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;
I 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
im having some dificulties in the combobox of Flex 3, after defining the dataProvider and filling the combobox, how can i remove the items in the combobox later (without removing items in the dataprovider)? if i set the provider to "" or null, the items in the combobox are still there
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?
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]...
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,
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?
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?
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 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.
The following for loop removes children from their parent if they're in the display list. It works correctly, but I also want to remove each child from memory with the same loop.
Below is a function set that's used to get info from an XML source(s) and populate a List Component (videoList). Works great. The second function loads data from a separate XML source and populates the SAME List Component. When the second function is called it loads the data in addition to the existing data into the List Component. I want it to REPLACE the data. How would I accomplish this?
public function getXMLdata(event:Event):void { var campXML:XML = new XML(xmlLoader.data); var vid:XML; for each(vid in campXML.vid) {
I am adding few items dynamically from the library to the stage by creating instances. If I remove them using removeChildAt() then the item gets removed from the display but exists in the memory. How can I remove this from memory?
I have a Listbox whith a ArrayCollection as datasource. I'm trying to remove the selected items from the ArrayCollection to update the list.Here is how I coded the remove function:
for each (var item:Item in theList.selectedItems) { theArrayCollection.removeItemAt(theArrayCollection .getItemIndex(item)); }
This works fine as long as the ArrayCollection is not sorted. When I apply a sort I get a RangeError from ListCollectionView.removeItemAt.
I have a large swf that is embedded in Director as a sprite I now want to put it onto a web page, so file size is critical Is there a way to remove unused library items when publishing so that file size is reduced? Is there another way to compress the swf so it is much smaller?The current size is about 25 Mb.What about streaming the swf?I'm not talking about streaming video or audio, just any Flash content.In Director, there is a way to right-click on a cast member and choose "find in score".If something isn't found it means that it either is not used in the movie or is implemented through code
I want to iterate over an ArrayCollection in Flex while there can be items added and removed.
Since i didn't find a way to use a "classic" Iterator like in Java, which would do the job. I tried the Cursor. But it doesn't really work the way i want it to be ;) So how do I do it nicely ?
var cursor:IViewCursor = workingStack.createCursor(); while (!cursor.afterLast) {
I have an ArrayCollection that is the dataProvider for a spark.components.List, which has allowMultipleSelection="true". There is a "Remove Selected Items" button which initiates the removal of all the selected items from the ArrayCollection upon being clicked.
I currently use the following method:
myList.selectedIndices.sort(ascendingSort); // remove items, counting backwards for (var i:uint = myList.selectedIndices.length; i > 0; i--) { myArrayCollection.removeItemAt(myList.selectedIndices[i-1]); }
where ascendingSort does what you expect ;). It works fine, and I know that it will always work.
However, I did take note that if I neglected the sort altogether, to my surprise the removal still worked. The reason for this turned out to be that, when the removeItemAt is called, the selectedIndices are correspondingly updated.
So my question is: Can one rely upon a removeItemAt call updating the values in the selectedIndices? or might that turn out to be different between runtimes and/or Flex SDK versions?
I have a large swf that is embedded in Director as a sprite. I now want to put it onto a web page, so file size is critical. Is there a way to remove unused library items when publishing so that file size is reduced? Is there another way to compress the swf so it is much smaller? The current size is about 25 Mb. What about streaming the swf? I'm not talking about streaming video or audio, just any Flash content. Any tricks for speeding the process up so that the user doesn't have a long wait before the swf starts?In Director, there is a way to right-click on a cast member and choose "find in score". If something isn't found it means that it either is not used in the movie or is implemented through codeIs there a similar way in Flash of detecting unused items or automatically eliminating them when publishing?
Anybody any ideas on how to remove children from stage using AS3 if I store the reference to the objects in an array and they exist in different locations i.e they are not all children of the same parent?
I need to remove every object that is part of an array from the stage. What I have right now only removes one of the objects.
this.removeChild(enemyList.splice(0)[0]);
I've tried several variations of this with either the same result or an error. Also, what is the zero in hard brackets for? I haven't seen that in many tutorials/explanations, but when I take it out, I get all kinds of errors.