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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:02:48+00:00 2026-05-20T14:02:48+00:00

I have a class member in an ActionScript 3 class that looks something like

  • 0

I have a class member in an ActionScript 3 class that looks something like this:

private var m_myvect :Vector.<MyType> = new <MyType>[];

I’m exposing it through a getter, like this:

public function get mydata() :Vector.<MyType>

Which doesn’t help when I use it like this:

for (var o:Object in inst.mydata)
{
    ...
}

… because the type of o is not MyType, but Number instead, because it enumerates the vector indices instead of the data.

How would I expose only the data within the vector in a way which:

  • Allows me to use for(a in b) syntax
  • Does not expose the data in a way which allows it to be modified?
  • 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-20T14:02:48+00:00Added an answer on May 20, 2026 at 2:02 pm
    for( var i:int = 0; i < mydata.length; i++ )
         // this will loop using the index - get your object using mydata[i] - it will be typed
    
    for ( var o:Object (or String) in mydata )
         // this will loop through using the keys - it's more for looping through Objects and Dictionaries
    
    for each( var type:MyType in mydata )
         // this will loop through using the values - what you're looking for
    

    The only way to expose data that stops it from being modified (i.e. adding/removing items from the Vector, or changing the data in MyType) is to do it through functions on the parent object (that holds the Vector).

    e.g.

    public function changeSomething( index:int, item:* ):void
    {
        // make sure the index is in bounds
        if( index < 0 || index >= this.m_myvect.length )
            return;
        this.m_myvect[i].whatever = item;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class that has a private static member: class Base {
If you have a class member that is static and public . Would you
I have class with a member function that takes a default argument. struct Class
I have a class in C++ with the following member: map< someEnum, vector<SomeObject*>* >
Let's say I have a class that has a member called data which is
I have a function inside a class that returns a reference to a member
Which class member can I use to return the number of members, that have
I have a class with the following member functions: /// caller pid virtual pid_t
Suppose I have a class module clsMyClass with an object as a member variable.
I have seen member functions programed both inside of the class they belong to

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.