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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:26:10+00:00 2026-05-26T23:26:10+00:00

So I am writing a program which uses Dictionary to store objects. For example

  • 0

So I am writing a program which uses Dictionary to store objects. For example

var dictionary:Dictionary=new Dictionary();
var myObject = new myObject(var1, var2, var3);

dicionary["key"]=myObject;

where var1, var2, and var3 are simply means of assigning values to variables in myObject.

my question is, can I access values or functions that are found in myObject? In myObject class I have some getters and setters. Can I use a getter to get the value of var1 for example.

dictionary["keys"].getVar1()?

kind of thing.

  • 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-26T23:26:11+00:00Added an answer on May 26, 2026 at 11:26 pm

    Sure, just as

    var obj:MyObject = dicionary["key"];
    trace( obj.getVar1() );
    

    works, you can do it without the variable, in a single line.

    trace( dicionary["key"].getVar1() );
    

    Just beware of the type, you will get errors if

    • the key doesn’t exist
    • the value for the key is null
    • the value for the key is of another type

    So it might be a good idea to check for these things before accessing any methods directly.


    However, if you are using Strings, a common Object is the usual solution. It works as an associative array:

    var dictObj:Object = [];
    dictObj["key"] = myObject;
    

    The Dictionary on the other hand is used when you need non-string objects as keys.

    var dictionary:Dictionary= new Dictionary();
    var key:MyKeyObject = new MyKeyObject();
    dictionary[key] = myObject;
    

    One last note: class names are usually written in CamelCase

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

Sidebar

Related Questions

I'm writing a program which uses regex to match incoming data. The regex works
I'm writing a c# application which uses automation to control another program. Naturally that
I am writing a c++ program which uses boost library for matrix operations. I
I am writing a program in C++ which uses the CLAPACK ATLAS library. However,
I'm writing a DLL which a java program uses to call the WinAPI in
I'm writing a program which uses the wPCAP library. I managed to get out
I am writing a clojure program which uses the STM. At the moment I
I'm writing a program that uses an Event class, which has in it an
I'm writing a program that uses OOP to store student records. At the moment
I'm writing a Java program which uses a lot of CPU because of the

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.