Actionscript 3 :: Removing Multiple Items From An ArrayCollection Using SelectedIndices

Dec 5, 2011

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?

View 2 Replies


Similar Posts:


Flex :: Iterating Over ArrayCollection While Adding And Removing Items

May 24, 2011

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)
{

[Code]....

View 5 Replies

Arraycollection - Flex 3 Removing Items From An Array Collection When The User Clicks A Button And Reflecting That In A Repeater

May 18, 2011

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:

[Code]...

View 2 Replies

Actionscript 3.0 :: Remove The Items In The Combobox Later (without Removing Items In The Dataprovider)?

Feb 6, 2009

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

View 1 Replies

Flex :: Swap Two Items In An ArrayCollection

Oct 11, 2010

I am trying to swap two items in an ArrayCollection with this code.

[Code]...

When debugging the code I can see that curItem and swapItem are the correct objects, but when I do my first setItemAt, it replaces the one I wanted but also one that I didnt want.

View 1 Replies

Flex :: ArrayCollection Removing Sort?

Aug 3, 2009

After applying a numeric sort to my dataprovider(Array Collection), I can not reorder the items via a tilelist. Do I need to remove the sort from the arrayCollection. If so, is it just a case of setting collection.sort = null ?

var sortField:SortField=new SortField();
sortField.name="order";
sortField.numeric=true;
var sort:Sort=new Sort();
sort.fields=[sortField];

View 3 Replies

ActionScript 3.0 :: Binding ArrayCollection Items To Vars?

Jan 19, 2011

I have an arrayCollection that is populating a chart. Can I bind the array items to vars that I can then modify?
 
private var ratingAC:ArrayCollection = new ArrayCollection([
{ Rating: 10 }, // [0] positive
{ Rating: 20 }, // [1] neutral
{ Rating: 60 }  // [2] negative

[code]....

View 1 Replies

Flash :: Flex - ArrayCollection - Adding And Removing A FilterFunction?

Jun 13, 2011

I am using Adobe Flash Builder 4 Premium. I have a mx:DataGrid and a s:TextInput, and I am trying to set up a search box that filters the DataGrid on each key press.his page shows a nearly perfect example of what I'm trying to do, except that I'm setting this up in a s:TitleWindow, which is brought up as a popup using the PopUpManager. The list I'm trying to filter can be very large. It is a list of usernames, fetched from a MySQL database via PHP. Since it can be so large, I want the list to be populated once in the main application and then referenced in the popup window so that it doesn't have to fetch all the usernames each time the user opens the popup.I have all of this working fine for the first time you bring up the popup, but if you close it and bring it up again, I get this runtime error:I also get this error if I attempt to set the filterFunction back to null just before closing the popup.See sample code below:

Main Application:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

[code]......

View 2 Replies

Flex :: Count Duplicate Items In XMLList And Assign Them Into An ArrayCollection?

May 19, 2010

I've following XMLList ,

<party/>
<party/>
<party/>
<party>A</party>

[Code]...

I would like eliminate blank node and to make an ArrayCollection like ( with count of individual party),

tArr = new ArrayCollection([ {Party:"A", Count:3},
{Party:"B", Count:2},
{Party:"C", Count:3},

[Code]....

View 2 Replies

ActionScript 3.0 :: Removing Items From Memory Using Loop?

Feb 18, 2009

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.

View 1 Replies

ActionScript 3.0 :: Removing Items From List Component?

Oct 27, 2008

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) {

[Code].....

View 3 Replies

ActionScript 3.0 :: Removing Stage Items From Memory

Apr 14, 2010

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?

View 2 Replies

Flash :: Removing Items From An Array Using .splice?

Aug 10, 2011

I'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.

View 2 Replies

ActionScript 3.0 :: Removing The Selected Items From A List?

Jan 22, 2010

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.

View 0 Replies

ActionScript 3.0 :: Removing Items From An Array In For Loop?

Dec 9, 2009

I could pop, shift, splice or slice it out of there (hey, that had a nice ring to it...)

how to properly remove items from an array while in the middle of a for loop:

Code:
//This will cause errors, because if the condition is met, it will skip the next array in line
for (var i:int = 0; i < arr.length; i++)

[Code].....

If someone is reading through my code, will they understand what I am doing without me having to clarify with comments each time?

View 4 Replies

Removing Unused Items / Optimizing File Size?

Jun 3, 2009

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

View 3 Replies

Flex :: Removing The Border At The Bottom Of The List Items?

Jul 21, 2011

Highlighted portion in red! How do i remove it? Code to render list is below:

<s:List id="ui_lstIndexList" width="175" height="600" fontFamily="TwinCen"
fontSize="24"
alternatingItemColors="[]" borderVisible="false" downColor="#7fceff"

[code].....

View 3 Replies

JavaScript :: Removing Items From Data Bound Array

Mar 26, 2009

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] .....

View 5 Replies

IDE :: Optimizing File Size / Removing Unused Items?

Jun 3, 2009

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?

View 1 Replies

ActionScript 2.0 :: Multiple Buttons Activating Multiple Items?

Jan 5, 2010

I have a map with a list of items to the side. I want the list to work as buttons and highlight both the button and the particular image on the map... and when you click you link to a certain location.I also want to be able to MouseOver the map, have both the image on the map and the corresponding 'button' from the list highlight - but when you click, you go to a different location than if you would have clicked from the list.I have it set up - but something is conflicting. Here is how I have my code set:

Code:
BUTTON_ONE.onEnterFrame = function(){
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();[code].......

View 1 Replies

Flex :: Handling Multiple Views Of The Same ArrayCollection

Feb 22, 2010

I have an ArrayCollection bound to a view, I use a filterFunction on this view to only display parts of the contents. Additionally I have another component where I want to display other parts of the ArrayCollection.

What I would like to do is wrap ArrayCollections around each other, meaning I could have one ArrayCollection containing the model data, and then two separate outer ones where I can set the filterFunction property (setting this in the model seems inappropriate in all cases). Is this possible somehow? If not, how else can this be solved, preferably without forcing model logic to end up in my view?

View 2 Replies

ActionScript 3.0 :: Removing List Items - Dispatch Click Event X Number Of Times Dependant On The Count Value?

Oct 8, 2010

I have a list of 10+ items. when i click back up the list 1 step i call the code below to remove a thumbnail image associated with that list item.

if(indice < count-i){mx.core.Application.application.removethumb.dispat chEvent(new MouseEvent(MouseEvent.CLICK));
}

HOWEVER: I would like that if - for example i am on item 10 and click to item 4 - all the thumbnails between 4-10 are removed. it it possible to dispatch this click event X number of times dependant on the - count value?? FOR REFERENCE: THIS IS THE CODE THAT REMOVES ALL ITEMS BEYOND THE ONE I HAVE SELECTED:

[Code]....

View 0 Replies

Flash :: Calling Geonames.org Service Multiple Times Adding Each Result To An ArrayCollection

Nov 14, 2011

I am using a service that returns JSON (geonames.org) and I'm putting the result in an array and dumping it to a datagrid. Now that works fine for one city like this [URL].. However, I want to call this service multiple times with different city names, so I created an XML list ad figured I would iterate over the city list and get the results.

My question is how do I do this such that 1) all the lists are combined into one arraycollection and 2) this seems like I will have to chain the calls and wait for results which may or may not come back, so I thought I would ask the group about the best practice, and or resources to read and examples to build from.

View 1 Replies

Flex :: Mxml - Components Bound To Empty ArrayCollection At Load Time Don't Render As Expected When The ArrayCollection Is Updated?

Oct 27, 2009

I'm new to Flex and am using TileList bound to an ArrayCollection. The array collection is empty at load time, and then updates with the results from am HTTPService call. The problem is that the item renderers aren't being rendered as expected, I'm guessing because there was no data when they were first rendered at load time. Here's simplified example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>

[code].....

View 2 Replies

Actionscript 3 :: ArrayCollection Index Got Changed After Filter The Arraycollection?

Oct 7, 2011

I have a advanced datagrid and populating some data by using arraycollection. And i am filtering the arraycollection, the arraycollection index got changed.

Arraycollection:- [0] - name: abc
[1] - name: hello
[2] - name: hello1
[3] - name:hai

after filtering the arraycollection as 'hell' , the array collection is displaying like the below:

Arraycollection:-
[0] - name: hello1
[1] - name: hello

Can i know the reason why the index got changed after filter it?

* no server side code for filtering. it is only flex side filtering.

View 2 Replies

ActionScript 3.0 :: Adding Multiple Items?

Jun 3, 2010

I have entered the following code and both items do import, but i cant control the label of the second library item called "Cool"After doing some digging, i think i found out the class name of the second object was called "Cool" and the base class was "import flash.display.SimpleButton;" so it looked like i had to import that class at the top like i did! But still not working. and still no joy!I think i need to add in "public class Cool extends SimpleButton" so it inherits the SimpleButton class after the first public class and then create a new function called "public function Cool() " and then add the function body but when i go to do that it all goes wrong. Am i on the right track or am i missing a trick!!

package
{
import flash.display.Sprite;

[code].....

View 3 Replies

ActionScript 3.0 :: Add Multiple Items To A HitTestObject?

Apr 11, 2012

I have a horizontally scrolling flying game involving a character and diferent types of food moving across the screen from right to left which the character has to collect ("hit"). I have the hitTestObject working for 2 different food movieclips with one item belonging to a healthyList, and the other to a junkList.

how to add more items (movieclips) to each of the lists, so that I have for example 6 items in the healthyList and 4 items in the junkList. 
 
Below is the code in my Engine.as file. The red highlighted text is the code that creates the problem. I thought that I just needed to add this line in order to add another item to the "healthyList" of food types, but I obviously have it in the wrong place or have the wrong code completely.

package
{
import flash.display.MovieClip;
import flash.display.Stage;

[Code]......

View 7 Replies

ActionScript 2.0 :: Create Multiple Items Behind Ui?

Aug 5, 2009

What I'm trying to do is have multiple items appear and go behind the ui with the next one coming under previous one also.

View 0 Replies

IDE :: Automatically Set Distance Of Multiple Items?

Feb 16, 2009

I lose a lot of time setting it manually. Is it possible to do it automatically ?

View 3 Replies

Actionscript 3 :: Removing Multiple Movieclips?

Feb 12, 2012

I'm developing a game.I've attached random movieClips from library. I've movieClips named picLeft1, picLeft2, picLeft3 and so on in library. Its working fine but i'm having problem removing it. the code below is for the attachment of movieclip. Here ranque is an array which stores randomly generated numbers up to 5 and HolderL is the movieClip in which I want to attach the movieClip. And q is a sprite.

for (var i:int = 0; int<3; i++) {
que_mc.push("picLeft"+ranque[i]);
var que_mc_class:Class = getDefinitionByName(que_mc[i]) as Class;

[code].....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved