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 407859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:38:09+00:00 2026-05-12T17:38:09+00:00

So in actionscript 3, instances of the Object class can be used an as

  • 0

So in actionscript 3, instances of the Object class can be used an as associative array:

var doNotHaveSexWith:Object = new Object();
doNotHaveSexWith['mum'] = new Person(...);
doNotHaveSexWith['dad'] = new Person(...);
doNotHaveSexWith['dave'] = new Person(...);

Say I have some class, and one of it’s members is a read only ‘Object’ which contains my collection of people.

I think code readability takes a major hit if I return this ‘Object’, as how would the programmer know what to do with it?
The only way someone is going to know that it is a collection is if they read the code or the comments…

What’s the best way to signal that an Object is a collection, rather than a simple object?

Options:

  • Create a dynamic class, simply
    extending from Object, called
    “AssociativeArray” or something, just
    so the code becomes more readable…

  • Use something like the AS3
    Datastructures Library
    , though this
    seems like a bit of overkill.

  • Just append the word Collection to
    the end of the variable name?

For example:

var hotPeopleCollection:Object = new Object();
hotPeopleCollection['me'] = new Person(...); 
hotPeopleCollection['sandrasully'] = new Person(...);

What do you think?

Update: I’ve decided to go with a custom class extending Dictionary. This way I can wrap a sensible access function around the searching function: hasOwnProperty and give the class a meaningful name.

I chose Dictionary over Object for two reasons:

  1. Dictionary makes more intuitive sense for a collection
  2. Dictionary appears to perform at O(1) for searching. See this fairly
    informal dictionary vs array vs object performance benchmark
  • 1 1 Answer
  • 1 View
  • 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-12T17:38:10+00:00Added an answer on May 12, 2026 at 5:38 pm

    Use a dictionary.

    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Dictionary.html

    You can still use a string for your key, or any object for that matter.

    var dict:Dictionary = new Dictionary();
    var obj:Object = new Object();
    var key:Object = new Object();
    key.toString = function() { return "key" }
    
    dict[key] = "Letters";
    obj["key"] = "Letters";
    
    dict[key] == "Letters"; // true
    obj["key"] == "Letters"; // true 
    obj[key] == "Letters"; // true because key == "key" is true because key.toString == "key"
    dict["key"] == "Letters"; // false because "key" === key is false
    delete dict[key]; //removes the key
    

    A lot of developer ( myself included ) will tell you: Never use an Object. You are basically blindfolding your compiler. Always either use a built in datatype or make your own. Now obviously you didn’t know about dictionaries in this case, but as a general rule, if you think you want to use a plain old Object datatype, think again.

    Update:

    Another link you might find helpful:

    http://www.gskinner.com/blog/archives/2006/07/as3_dictionary.html

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

Sidebar

Related Questions

In ActionScript, how can you test if an object is defined, that is, not
Code inside Actionscript: var methodName4:String = startupload; var instance4:Object = null; var method4:Function =
I'm new to flash, actionscript, and the class/method/static/instance paradigm. I do have one class
How do you get an instance of the actionscript class Class from an instance
ActionScript 3 / Flex 3 - Adding custom events to a class Say I
I have an actionscript file that defines a class that I would like to
Is it possible in Actionscript 3 to create a weak reference to an object,
I'm new to ActionScript and Flex 3... I'm trying to develop an MVC 100%
I'm new to Java, but have some OOP experience with ActionScript 3, so I'm
In my main Actionscript file i have a instance of a body class that

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.