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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:50:32+00:00 2026-05-20T03:50:32+00:00

Coming from a Delphi background, I am used to be able to have class

  • 0

Coming from a Delphi background, I am used to be able to have class references/pointers of a specific superclass, example:

#!pas
var
  niceVar: class of TClassOne; // Delphi style
  badVar: class; // Only? allowed AS3 style to the best of my knowledge

begin
  niceVar := x;
  badVar := x;

  niceVar.staticMethodSpecificToTClassOne;
  TClassOne(badVar).staticMethodSpecificToTClassOne;
end;

What this means is that I don’t have to cast my variables to a specific class; they are of the correct Class beforehand. This also means that compile-time checking can be performed to make sure proper members are being accessed and I don’t have to check that niceVar is in fact of class TClassOne if niceVar was passed to a method.

#!pas
procedure test(var x: class of TClassOne);
begin
  x.someStaticMethod(true);
end;

// An entry point
var
  niceVar: TClassTwo; // Does not inherit from TClassOne

begin
  test(niceVar); // Error - niceVar does belong to the TClassOne "family"
end;

So just like a variable storing an object can be for a specific type and only objects of that class or subclasses of it are accepted, so to does “class of AClass” allow for variables of a specfic class to be limited to references to a certain class or those inherited from it.

I hope that makes sense somehow; I don’t know of specific nomenclature for the whole “class of SuperClass” thing.

So I’d like to do the same in AS3 as having variables/properties/parameters of type Class does not cut the mustard; its kind of like having all object variables/properties/parameters simply being Object instead of their proper, specific type.


Edit #1 – 2011-02-14 13:34
Syntax highlighting is messed up here; I want the code to be recognized as Object Pascal. Looking forward to this.


Edit #2 – 2011-02-14 15:11
Here is an example of what I would like to achieve with this in AS3.

Current code

public function set recordClass(aRecordClass: Class): void 
{
  if (!extendsClass(aRecordClass, TRecord)) 
  {
    throw new Error("TDBTable - Invalid record class passed.");
      return;
  }
  _recordInstance = new aRecordClass(this); // Compiler has no idea of the classes constructor signature, but allows this regardless.
}

What I’d like to be able to do

public function set recordClass(aRecordClass: TRecordClass): void 
{
  _recordInstance = new aRecordClass(this); // Compiler will know that I am creating a TRecord
}
  • 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-20T03:50:33+00:00Added an answer on May 20, 2026 at 3:50 am

    AFAIK, you have to stay with Class type. This is one of ActionScript limitations, same as Function is reference for all function types. AS 3.0 quite often forces run-time checks where in other languages were static checks – static type checking is not its strongest point.

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

Sidebar

Related Questions

I'm new to visual studio, coming from Delphi. I have a directory tree full
Coming from a Classic ASP background, I'm used to multiple forms on a page,
Coming from a java background, one of the things I am used to is
Coming from a Perl background, I have to say I prefer cpan Foo::Bar to
Coming from a background using Visual Studio and Notepad++ I'm used to the indent
Coming from Haskell I was used to have concise operators like not (x `elem`
Coming from a C++ background, I'm used to sticking the const keyword into function
Coming from a Java background, I'm wondering why List in Scala doesn't have a
Coming from a corporate IT environment, the standard was always creating a class library
Coming from a background, I'm familiar with GUI editors that do a poor job

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.