Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 496623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:42:13+00:00 2026-05-13T05:42:13+00:00

For example I have two ArrayCollection’s – firstAC and secondAC. If I do secondAC

  • 0

For example I have two ArrayCollection’s – firstAC and secondAC. If I do secondAC = firstAC, and than I make changes to secondAC (prehaps put a filterfunction on it) it somehow propagates to firstAC, would anyone tell me why that happens in Flex or Actionscript 3?

What can I do if I only want secondAC to get all data from firstAC but then when I make changes to secondAC it does not show in firstAC?

Thanxs a bunch for answers!
Ladislav

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:42:13+00:00Added an answer on May 13, 2026 at 5:42 am

    In ECMAScript languages (AS1-3, JavaScript, et al.), when you use

    var foo = //some value which is not a String or a Number
    

    what you are really saying is “foo now points to the same object as that other variable.” This means that in this situation, both arrays will be the same value:

    var foo:Array = [ 1, 2, 3 ];
    foo = bar;
    bar.push( 4 );
    trace( foo ); // 1, 2, 3, 4
    

    This also works for functions:

    var foo:Array = [ 1, 2, 3 ];
    adder( foo );
    function adder( bar:Array ):void {
        bar.push( 4 );
    }
    
    trace( foo ); // 1, 2, 3, 4
    

    and it even works with XML:

    var xml:XML = <root><foo/></root>;
    var bar:XML = xml;
    bar.children()[ 0 ].@bar = 1;
    trace( xml.toXMLString() ); // <root><foo bar="1"/></root>
    

    This is called “passing by reference” instead of “passing by value” or “passing by copy”. It means that every time that an item is referenced, each variable will point to the same object.

    There are many ways to get around this, and most of them depend on your context. For arrays, my favorite is Array.concat(), which returns a literal clone of the array. This means that anything I do to the returned value will not effect the original in any way. If I’m dealing with XML, however, I will do something like: var xml2:XML = XML( xml.toXMLString() );.

    In your case, I would actually recommend that you use:

    var secondAC:ArrayCollection = new ArrayCollection( firstAC.source.concat() );
    

    This has the major benefits of not only being faster (it relies on compiled code instead of Flex SDK code and it also does not first instantiate a new array and then re-populate it), but it also has the distinct benefit of being available in older versions of Flex 3’s SDK — it is entirely backwards compatible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example if I have an Enum with two cases, does it make take
Example: I have two shared objects (same should apply to .dlls). The first shared
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two websites, let's say they're example.com and anotherexample.net . On anotherexample.net/page.html ,
I have two List's which I want to check for corresponding numbers. for example
Simplified for example, I have two tables, groups and items . items ( id,
Example: I have two tables in my database called classA and classB , and
for example i have two ranges (1) 0 to 3 (2) 10 to 15
For example we have two strings: string s = cat; string s1 = dog;
For example I have two model objects, Person and Address. Address has a reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.