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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:56:05+00:00 2026-05-12T11:56:05+00:00

We have the Class object (an object that reference a Class) so you can

  • 0

We have the Class object (an object that reference a Class) so you can create objects from that Class object:

var classObject:Class = package.to.class.AClass;
var objectFromClass:AClass = new classObject();

Now, I want to know what object is referenced by classObject. For example:

function Creator(classObject:Class):AClass
{
    // here I want to know what class is referenced by classObject
    return new classObject();
}

var classObject:Class = package.to.class.AClass;
var objectFromClass:AClass = Creator(classObject);

This works, but what if I pass a Class object that do not reference to AClass? I want to know if this happends and make somthing about it.

— EDIT —

Searching I found this function

flash.utils.getQualifiedClassName(value:*):String
This function returns the name of the class, for example:

var name:String = '';
// name = ''

name = flash.utils.getQualifiedClassName(package.to.class.AClass);
// name = 'AClass'

name = ''
// name = ''

var anInstance:AClass = new AClass();
name = flash.utils.getQualifiedClassName(anInstance);
// name = 'AClass'

So, all I have to do is to compare the results of that function:

function Creator(classObject:Class):AClass
{
    var anInstance:AClass = new AClass();
    var className:String = flash.utils.getQualifiedClassName(anInstance);
    var classObjectName:String = flash.utils.getQualifiedClassName(classObject);

    // here className and classObjectName are 'AClass' :)
    if (className != classObjectName)
        throw new Error('The classes are different');

    return new classObject();
}

var classObject:Class = package.to.class.AClass;
var objectFromClass:AClass = Creator(classObject);

— EDIT 2 —

Another method is to use the constructor property of the Object class:

function Creator(classObject:Class):AClass
{
    var tempInstance:AClass = new AClass();
    var tempClassObject:Class = Object(tempInstance).constructor;

    if (classObject != tempClassObject)
        throw new Error('The classes are different');

    return new classObject();
}
  • 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-12T11:56:05+00:00Added an answer on May 12, 2026 at 11:56 am

    I found that the most simplest (not know if it’s the fastest) way to accomplish this task is in the next example:

    function Creator(classObject:Class):AClass
    {
        var anInstance:Object = new classObject() as AClass;
        if (anInstance == null)
            throw new Error('The classes are different');
    
        return new classObject(); // or return anInstance as AClass;
    }
    

    This also works if AClass is an Interface.

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

Sidebar

Ask A Question

Stats

  • Questions 211k
  • Answers 211k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer use git mv and everything will be AOK. Why not… May 12, 2026 at 10:13 pm
  • Editorial Team
    Editorial Team added an answer You can accomplish this by using jQuery's .data(key, val) method… May 12, 2026 at 10:13 pm
  • Editorial Team
    Editorial Team added an answer What is the ItemsSource of your ListBox ? A list… May 12, 2026 at 10:13 pm

Related Questions

I have an object for which I'd like to track the number of threads
My program, alas, has a memory leak somewhere, but I'll be damned if I
Suppose I have a table in my database that is made up of the
The problem is basically this, in python's gobject and gtk bindings. Assume we have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.