From ArrayCollection to Array in DataBinding

Hi,
I am trying to use somebody else's visual component (have src code of that mxml),
which uses Array items as a DataSource.
In my program I use ArrayCollection to hold my data (from the data feed - changes in real time).
I need to pass some data from my ArrayCollection into that component inside the binding,
something like:
<view:Component1  items="{dataArrayCollection}"?? />
currently have in Component1.mxml:
public function set items(a:Array):void {...}
Since that component is pretty complicated, I would not want to break its logic,
so I am thinking of adding some data adapter, public method to Component1 like:
public function set dataProvider(ac:ArrayCollection):void {
Array tempArr = new Array();
// copy some data from ac -> tempArr
items(tempArr);
and do: <view:Component1  dataProvider="{dataArrayCollection}" />
Is there a more efficient way of doing that (I guess, "set dataProvider" will be called a lot, on each update)?
I don't think I can just straight convert ArrayCollection -> Array, need just a small subset of data.
Please advise.
TIA,
Oleg.

Alex,
A friend suggested me another solution, which I tried and it seems to work and be more straightforward:
main.xml:
[Bindable]
  private var ac : ArrayCollection;
<component dataProvider="{ac}" />
Component.xml:
[Bindable]       
public var dataProvider:ArrayCollection;
private function onCreationComplete():void {
   dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, onDataProviderUpdate);
public function onDataProviderUpdate(e:*=null):void {
                if (dataProvider == null) {                  
                    return;
                var aca:Array = dataProvider.source;                                
                var dev1:Object = aca[0];    // process only 1 element of that AC                   
                var dev:Device = new Device();
                dev.cpu = dev1["cpu"];
                // pass to items array
                if (_items == null) {    // if new                    // _items - component's data array              
                    _items = new Array();
                    _items.push(dev);                                                
                } else {                   
                    _items.push(dev);    
                    updateData();                   
                updateView();                          
Do you like that solution ?
The only problem I see is that when the feed runs, the size of the browser memory grows fast,
so by element 60 it slows down, by 95 memory consumption grows to 1.4GB and browser crashes.
I do not think it is related to that data binding, but not positive.
Can it be array.push() ?
Any way to force garbage collection in Flex ?
Please advise,
Oleg.

Similar Messages

  • Best Way to Create Array of Values From ArrayCollection

    I often use Arrays of values from ArrayCollections in my
    application in order to facilitate faster performance when
    filtering other Collections.
    For instance, let's say I have an ArrayCollection of Objects
    with the properties "id", "name", "label", and "isActive". What
    would be the best way to get an Array of all the "id" values?
    Right now, I am looping over the ArrayCollection, and adding
    the value of the property I need to an Array using Array.push().
    For larger Collections, this seems like overkill. I was wondering
    if anyone knew of some quicker way to get an Array of values of one
    property from an Array Collection.
    My current method for doing this is attached below...
    Thanks.

    No, that won't work - toArray() simply returns the entire
    Collection as an Array.

  • How to convert from XML to Array ?

    how to convert from XML to Array ?
    thanks in advance

    this is a segment of the xml object:
    var myXML:XML =
    <data>
    <task>
    <taskID>2</taskID>
    <startDate>2/15/2007</startDate>
    </task>
    </data>
    i want to conver myXML into ArrayCollection: like this:
    private var expenses:Array = [
    {taskID:"1", startDate:"2/15/2007"},
    {taskID:"2", startDate:"4/15/2007"}
    how i can do it ? and tell me how to retrieve the data from
    the collection
    thanks

  • Getting one character at a certain position from a string array

    Hi, i'm new at learning java, but have strong experience at C++ and asm. How would i get one character at a certain positon from a string array.
    for example:
    String Phrases[] = {"To be or not to be, that is the question","The Simpsons","The Mole","Terminator three rise of the machines","The matrix"};
    that is my string array above.
    lets say i wanted to get the first character from the first element of the array which is "T", how would i get this

    ok well that didn't work, but i found getChars function can do what i want. One problem, how do i check the contents of char array defined as char Inchar[];

  • Deleting data from a 2D array based on the id of the second column

    Hello
    I hope someone can help me. I have come across a hurdle in the programming of my application.
    1.
    I have a 2D array, the first column of this array contains my data and the second column contains an id, which is either 0 or 1.
    I have sorted this 2D array based on the id column so that the data corresponding to the 0’s is on top part of the array and the data corresponding to the 1’s follows it (on the bottom of the array).
    I want to delete that data (rows) of this sorted array that correspond to the 1’s and keep only the data (rows) that correspond to the 0’s.  
    So I would end up with a new 2D array that has only the data that I want on the first column and 0’s on the second column.
    I have hundreds of these 2D arrays resulting from my program (using a for loop) hence I want to automate this procedure. The length of the selected data arrays will vary.
    2.
    Once I can do this I will want to remove the id column (with the 0’s) from the 2D array and would like to build a new array with only the data from the first column (which may be of different length).
    So I want to end up with a 2D array with columns corresponding to the selected (1st column) data from the (original) 2D arrays. These data may be of different lengths so when building this new array I may need to do some padding. Will labview do this automatically?
    I hope that this is clear.
    Best wishes,

    Attached is a different approach - you don't need to do any sorting.
    The outer FOR loop assumes you have all the arrays available at once. If you are reading a file, modify it accordingly.
    You may or may not want the TRANSPOSE function on the final results, depending on what you want to do with it.
    Yes, when you assemble N-dimensional arrays into (N+1)-dimensional arrays, LabVIEW automatically pads for you.
    Enjoy.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    Extract Marked Data.vi ‏40 KB

  • Removes duplicates from a sorted array without having to create a new array

    Funcation removes duplicates from a sorted array without having to create a new array

    Funcation removes duplicates from a sorted array
    without having to create a new arrayIs a 'funcation' like a vacation but more fun or
    something?LMFAO. You just jumped with both feet on one of my biggest peeves. I've been outed!
    Actual words/phrases I've seen used which I hate with every fiber of my being:
    "Mrs. Freshly's"
    "McFlurry"
    "Freshissimo"
    "Spee-dee"
    "Moons Over My Hammy"
    One of my favorite SNL skits had Will Ferrell leading a panel of movie reviewers (they're the worst for this kind of junk). Each one had some cheesy pun to describe their respective movie. Ferrell topped the show off with his endorsement of "Fantasia 2000 is Fantasgreat!"
    LOL.
    "Come to Slippy Village - it's a FUNCATION!"
    &#167; (runs off, laughing maniacally, head explodes)

  • Building DLLs from VIs with array as output

    Is there any special way to build DLLs from VIs having arrays as outputs. Suppose I have a VI "Random" with input "nrand" and output an array "the_random2". When I build DLL from the VI, I have something like this in my header file
    void __stdcall Random(long nrand, double the_random2[]);
    Now it returns void. So I have to pass the array as pointer and retrieve it. If I use Mathscript to load the DLL and call this function, how do I pass the pointer to the array "the_random2"? Simply speaking, any useful method to build DLLs with array outputs and the right way to call them from Mathscript would be appreciated.
    Regards
    NRK

    Hi,
    Building DLLs in LabVIEW is described in this tutorial.  
    Mathscript can call shared libraries such as DLLs, however make sure
    that they are compliant with the supported data types as stated here in
    this help page.  All supported functions for calling/loading shared libraries is described here. 
    Note that these functions are not supported with the base package.  The
    details of the sytax of each function is described in their specific
    help page.
    Hope this helps!
    Regards,
    Nadim
    Applications Engineering
    National Instruments

  • Random selection of rows from a 2D array then subset both the rows that were selected and those that were not. Please see message below.

    For example, I have a 2D array with 46 rows and 400 columns. I would like to randomly select 46 data rows from the 2D array. By doing the random selection it means that not all individual 46 rows will be selected some rows may appear more than once as there may be some duplicates or triplicates in the random selection. The importan thing is that we will have randomly selected 46 rows of data (no matter that some rows appear more than once). Then I would like to subset these randomly selected 46 data rows (some which will be duplicated, or triplicated, etc.) and then also find and subset the rows that were not selected. Does this make sense? Then i would like to do this say 10 times for this data set. So that then I will have 2 by 10 data sets: the first 10 each with 46 rows and the other 10 with n rows depending on how many WERE NOT randomly selected. i hope that my explanation is clear. I am relatively new to Labview. It is really great so I am getting better! If anyone can help me with this problems it will be great. RVR

    Start by generating randon #s between 0 and 45. Run a for loop X times and in it use the random function, multiply the result by X and round down (-infinity). You can make this into a subVI, which you can reuse later. In the same loop, or in a different one, use Index Array to extract the rows which were selected (wiring the result out of the loop with auto indexing causes it to be rebuilt into a 2D array).
    One possible solution for the second part would be to go over the array of randomly generated numbers in a for loop and use Search 1D Array to find each of the numbers (i). If you get -1, it means the row wasn't selected and you can extract it.
    I hope this puts you on the right path. If not, don't be afraid to ask more.
    To learn more about LV, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide.
    Try to take over the world!

  • How to locate a substring from a character array

    I'm having trouble locating and counting two substrings from a character array
    my array contains the characters abababaa, I want to locate and count two substrings which are "aba" and "bab"
    I would appreciate any help, I'm not allowed to convert the character array to a string, Im using a for loop to iterate through the array but I cant figure out how to locate the substrings.
    thank you

    For 'aba' search, read one character at a time in a loop. When you find the first char 'a', see if the next char is b, and the one after that is a. If so,you have a match. Next, go through the loop beginning with the char that exists after that 'a' you found plus 2 (so you ignore the three chars you found) and repeat the above. continue finding matches until you reach the end of the array. Be sure when looking at the second and third char above, you dont go past the length of the array or it will throw an exception.

  • How to remove blank data from a byte array

    Hi All,
    How to remove blank data from a byte array. Suppose I created a byte array as byte[] b = new byte[8192] and i read the data as inputstream.read(b). If the data that has been received is only 1000 bytes length, how to find out how much data has been read or how to delete that blank 7192 bytes of data?
    Thanking you,
    Regards,
    Shankar.

    1) Always try to sidestep this by allocating only the necessary amount of space required...
    2) If 1 is not possible, you will have to index byte for byte how much data was read into the array which
    denotes reading byte for byte... not ideal as this is relatively slow...
    Are you reading from a file?

  • Converting string from file to array

    I'm new to LabVIEW and have been thrown into the middle of a project, so I need to get some code working fast! Can someone help me understand why the VI I've attached isn't working? I want to have a text file that contains a list of integers that will be used to reference particular elements in arrays within my program. I tried to follow an example I found, but the output that should be an array is coming out as a scaler. Any help would be super appreciated! Thanks!
    Solved!
    Go to Solution.
    Attachments:
    string_to_array.vi ‏9 KB
    exp.txt ‏1 KB

    First, let's explain the reason for your error: The reason why it's happening is that you're trying to do two different things at the same time. You're auto-indexing the array and you're trying to index the array inside the loop. When you wire an array to a for loop it auto-indexes the loop. Meaning LabVIEW knows how many times to run the loop - there is no need to wire to the N terminal. Also, the wire inside the loop will be an instance of the element of the array, not the array. So, the wire inside the loop is a scalar. Thus, the reason for the broken wire - you can't index a scalar.
    Also, I'm not sure what you're trying to do with the indexing of the one element of the cluster. The cluster is empty, so there's nothing to index. Presumably the file is there to tell you which elements to pull out from the "Amp2" array from the cluster. If so, remember that auto-indexing works both ways. If you connect an "outbound" wire to the edge of a loop it auto-indexed there as well, meaning the output will be an array.
    Please read the LabVIEW Help on auto-indexing.
    Now, given all of that, here is what your code should look like:
    Note the use of the Read From Spreadsheet File VI. It makes your life easier.
    Attachments:
    fixed code.png ‏22 KB

  • Number of 1s or 0s from a boolean array

    How to find the number of 1s or 0s from a boolean array. e.g. in 101011, there are four 1s and two 0s.
    Solved!
    Go to Solution.

    ABBPAK ha scritto:
    Hi,
    When you talk about the value change, how to predefine the first value and the last value. e.g. 1100011. here just twice a time value changes but there are four 1s and three 0s.
    thanks
    Did you focus on the word "sort"? 
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Reading HDD Temperature from a RAID Array (nForce4)

    Hello all!
    does anybody know of a program that can read the HDD temperature from a RAID Array?
    I'm using Speedfan at the moment but the author doesn't seem to like nVidia at all, thus no support for us.

    I read:
    Quote
    To sum it up : The nvidia raid controller doesn't support it .
    That's not true really, because the nVidia utilities support reading the SMART status from the array. So it can be done, it's only matter of having the documentation or doing some research. However Speedfan's author doesn't like nVidia so he's not going to do anything, unless a doc is handed to him.
    I wonder whether the linux community has worked it out 

  • Will mavericks boot from a raid array?

    Will OS X Mavericks boot from a raid array?  I know Lion didn't support booting from a RAID.

    Well, since no one seems to want to answer this question I've done a little research and answered it myself.  Yes, you can boot from a RAID while running OS X Mavericks.  The only setback is that you can't create a recovery partition.
    While installing Mavericks on a RAID it will prompt you to OK installing without a recovery partition.  In laymen's terms it means you have to keep your own backup.  If your RAID fails you will lose the data or whatever is stored on it.  Simply keep your own backup and you'll be fine.  This is the way most people do it anyway.  Yes, it may be considered old wave but it's still the best option.  It's an absolute.  If you have a backup, you never to have cross your fingers, pray and hope the recovery process actually works!
    That being said, you can create some really souped up Macs.  I actually installed two 480GB SSDs into a 2.8GHz Macbook Pro and the response is phenominal !!!  From power on button to sign in screen is less than 10 seconds on a 5 year old Macbook Pro !!!  If you hate seeing the little spinning wheel while shutting down this will cure your distress.  Shutting down is instantaneous.  I love it !!!  RAID and SSDs are the best !!!  A newer Quad-Core machine has to be even faster which is hard to imagine.
    That's my 2 cents ...

  • Getting int values from a char array

    Hi,
    I need to make a fast program which reads lots of data from files and process them. I need to interpret these data as int's. To be more efficient and avoid to make a lot of disk access, I allocate in memory buffers part of the data, then process it and then allocate new data. The problem is that if I want to allocate data in memory buffers, all the methods that enables me to do that receceive as a parameter only a an array of chars, and as I have mentioned I need to interpret the data as a 4 bytes int. The static methods of Array to get the int value from a position ar not useful because the onlye get the int value of the indexed byte (or char); this method doesn't take 4 bytes from the index to build an int.
    My question is: is there any way to build an int from 4 bytes? or can I get the int's in this way directly from the buffer?
    Thank you,

    Isn't this one of the prime examples of using java.io.DataOutputStream and java.io.DataInputStream?

Maybe you are looking for

  • New infinity 2, line switched but no notice or com...

    Hi, after ordering (infinity/tv/phone), today my line was switched to BT (thanks for the numerous text2phone messages....) and after checking with the order tracker it says completed (for phone) but no details for BB or TV? is it always like this?  S

  • Which is better JSF or JSP

    We are planning to start a new Web Based Project, which one we should prefer for UI either JSF or JSP

  • Displaying errors of idocs in a report

    i want to display errors of idoc along with the status in a report. can any suggest me the correct method?

  • Update personalized Adobe Air

    Dear sir, I have an exclusive version of Adobe Air developed for a Brazilian books publisher, which was developed about a couple of years ago. I need to update this version to the newest Air version, which archives and folders should I substitute to

  • IS-U and SD BP integration

    hi... According to the BP creation, i have created reference customer using XD01 as MUST_ALL with plant and sales org. I have already created in IS-U using FPP1 I have maintained the reference customer settings in the IS-U - mater data - setting for