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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:28:38+00:00 2026-06-13T09:28:38+00:00

I want to get the declared type my number, but I have no idea

  • 0

I want to get the declared type my number, but I have no idea how to get them. So I wrote a test with possible detection methods:

logNumber(Number(3.5), "Number");
logNumber(Number(3), "Number");
logNumber(Number(-3), "Number");
logNumber(uint(3), "uint")
logNumber(int(3), "int")
logNumber(int(-3), "int")

function logNumber(value:*, expected:String):void
{
    trace("\n\n\n ");
    trace("** Input value: " + value + "\n** Expected: " + expected + "\n")
    trace("getQualifiedClassName: ", getQualifiedClassName(value) + check(getQualifiedClassName(value), expected));

    switch (value)
    {
        case value as uint:
        {
            trace('as: uint' + check('uint', expected));
            break;
        }
        case value as int:
        {
            trace('as: int' + check('int', expected));
            break;
        }
        case value as Number:
        {
            trace('as: Number' + check('Number', expected));
            break;
        }
    }

    if(value is uint) trace("is: uint" + check('uint', expected));
    else if(value is int) trace("is: int" + check('int', expected));
    else if(value is Number) trace("is: Number" + check('Number', expected));

    trace("describeType name:" + describeType(value).@name + check(describeType(value).@name, expected));

    trace("typeof: ", typeof(value)  + check(typeof(value), expected));

    trace("\n" + describeType(value))
}

function check(type:String, expectedType:String):String
{
    return "\n  » " + (type == expectedType ? "good" : (type.toLowerCase() == expectedType.toLowerCase() ? "almost good" : "wrong"))
}

This outputs the following results to my trace panel:

3.5 as Number

** Input value: 3.5
** Expected: Number

getQualifiedClassName:  Number
  » good
as: Number
  » good
is: Number
  » good
describeType name:Number
  » good
typeof:  number
  » almost good

<type name="Number" base="Object" isDynamic="false" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constructor>
    <parameter index="1" type="*" optional="true"/>
  </constructor>
</type>

3 as Number

** Input value: 3
** Expected: Number

getQualifiedClassName:  int
  » wrong
as: uint
  » wrong
is: uint
  » wrong
describeType name:int
  » wrong
typeof:  number
  » almost good

<type name="int" base="Object" isDynamic="false" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constructor>
    <parameter index="1" type="*" optional="true"/>
  </constructor>
</type>

-3 as Number

** Input value: -3
** Expected: Number

getQualifiedClassName:  int
  » wrong
as: int
  » wrong
is: int
  » wrong
describeType name:int
  » wrong
typeof:  number
  » almost good

<type name="int" base="Object" isDynamic="false" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constructor>
    <parameter index="1" type="*" optional="true"/>
  </constructor>
</type>

3 as uint

** Input value: 3
** Expected: uint

getQualifiedClassName:  int
  » wrong
as: uint
  » good
is: uint
  » good
describeType name:int
  » wrong
typeof:  number
  » wrong

<type name="int" base="Object" isDynamic="false" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constructor>
    <parameter index="1" type="*" optional="true"/>
  </constructor>
</type>

3 as int

** Input value: 3
** Expected: int

getQualifiedClassName:  int
  » good
as: uint
  » wrong
is: uint
  » wrong
describeType name:int
  » good
typeof:  number
  » wrong

<type name="int" base="Object" isDynamic="false" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constructor>
    <parameter index="1" type="*" optional="true"/>
  </constructor>
</type>

-3 as int

** Input value: -3
** Expected: int

getQualifiedClassName:  int
  » good
as: int
  » good
is: int
  » good
describeType name:int
  » good
typeof:  number
  » wrong

<type name="int" base="Object" isDynamic="false" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constructor>
    <parameter index="1" type="*" optional="true"/>
  </constructor>
</type>

It’s a lot to analyze, but some things are popping out:

  • If a Number equals 3.5, it will be outputted as Number, but if it is 3 it will be outputted as int/uint.
  • Its hard to detect if it is a uint or int, results are confusing and not consistent.

For a debug purposes (and just to understand how this works), I want the type that I have declared. How can I make a function that returns the right type?

  • 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-06-13T09:28:39+00:00Added an answer on June 13, 2026 at 9:28 am

    (If anyone wonders, I found a solution myself. Make sure you read
    @antonpaker answer too, it has useful information)

    There seems to be a reliable solution to find the right type of the number.
    However there are some restrictions; It’s only possible for public vars, and you have to pass the parent object. If you use describeType of the parent object gives the exact type of the Class properties, not how it is optimized at runtime. You have to find the property inside the object to find the right type of it.

    function getNameOfTypeOfProperty(object:*, property:String):String
    {
        return describeType(object)..*.(hasOwnProperty('@name') && @name == property).@type;
    }
    

    If you try this out on a simple MovieClip:

    trace("x:" + getNameOfTypeOfProperty(this, "x"));
    // Number
    
    trace("currentFrame:" + getNameOfTypeOfProperty(this, "currentFrame"));
    // int
    

    These values seems to be (always) right.

    (Note: This function will be added to the new Reflection module of the internal version of the Temple library and probably will be available in the next release. This class nicely caches describeType too, for optimizing the describeType call)

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

Sidebar

Related Questions

I have declared the following enum type in which I want the first member
I want to call Type.GetFields() and only get back fields declared as public const.
I want get as much as possible from Redis + Hiredis + libevent. I'm
Basically I want get data I already have accessed from javascript and passing it
I want to create a generic List<> whose type is declared at runtime. I
I have package in which I have declared cursor. And I want to return
I have a table containing a column of type Number create table tmp (
In my class, i have declared a delegate type, I am creating an instance
suppose you have a class Product, with members that are declared as nested type
I have some ArrayList s declared. Some of them are ArrayList<Integer> and other are

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.