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

  • SEARCH
  • Home
  • 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 3350620
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:48:32+00:00 2026-05-18T01:48:32+00:00

I have 2 dynamic objects and I want to build one to contain all

  • 0

I have 2 dynamic objects and I want to build one to contain all the properties:

var o1:Object = {prop1:val1,prop2:val2,prop3:val3};
var o2:Object = {prop3:val3a,prop4:val4};

and I need to obtain a third object that looks like that:

{prop1:val1, prop2:val2, prop3:val3a, prop4:val4};

Basically I need a way to iterate through the object properties and to add new properties to the third object. I have to mention I’m quite new to AS3/Flash/Flex.

  • 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-18T01:48:33+00:00Added an answer on May 18, 2026 at 1:48 am

    First question, do you really mean to have prop3 in both objects? you will need to decide what to do in case of a collision like that, which object has precedence.

    Secondly, check out the introspection apis: http://livedocs.adobe.com/flex/3/html/help.html?content=usingas_8.html

    something like this should work:

    public function mergeDynamicObjects ( objectA:Object, objectB:Object ) : Object 
    {
        var objectC:Object = new Object();
    
        var p:String;
    
        for (p in objectA) {
           objectC[p] = objectA[p];
        }
    
        for (p in objectB) {
           objectC[p] = objectB[p];
        }
    
        return objectC;
    }
    

    If the property exists in A and B, B’s will overwrite A’s. Also note that if the values of a property is an object, it will pass a reference, not a copy of the value. You might need to clone the object in those cases, depending on your needs.

    Note: I haven’t actually tested the above, but it should be close. Let me know if it doesn’t work.

    Updated to fix the errors. Glad it works for you though.

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

Sidebar

Related Questions

Say i have a object in dynamic memory (new) and inside one of its
I have JSON string that has nested objects with dynamic names that vary each
I have an anonymous type object that I receive as a dynamic from a
I'm wanting to have a simple duck typing example in C# using dynamic objects.
I have a simple object hierarchy, and I want to query each of the
What I have is a model which has one of it's attributes dynamic. This
We have a Salesforce app where we have some custom objects and want to
I have a list of pointers to objects. What I want to do is
Possible Duplicate: Javascript Objects: Dynamic variable names? I have a json string passed in
I have custom Question objects which I render into html form elements. I want

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.