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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:11:04+00:00 2026-05-15T00:11:04+00:00

AS3 Code: import flash.utils.Dictionary; var num1:Number = Number.NaN; var num2:Number = Math.sqrt(-1); var dic:Dictionary

  • 0

AS3 Code:

import flash.utils.Dictionary;
var num1:Number = Number.NaN;
var num2:Number = Math.sqrt(-1);
var dic:Dictionary = new Dictionary( true );
trace(num1); //NaN
trace(num2); //NaN
dic[num1] = "A";
trace( num1 == num2 ); //false
trace( num1 === num2 ); //false
trace( dic[num1] ); //A
trace( dic[num2] ); //A

Concerning the key comparison method…
“The Dictionary class lets you create a dynamic collection of properties, which uses strict equality (===) for key comparison. When an object is used as a key, the object’s identity is used to look up the object, and not the value returned from calling toString() on it.”

If Dictionary uses strict equality, as the documentation states, then how is it that num1 === num2 is false, and yet dic[num1] resolves to the same hash slot as dic[num2]?

  • 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-15T00:11:05+00:00Added an answer on May 15, 2026 at 12:11 am

    The description given by Adobe is neither exact nor correct to be honest, but it is simpler and covers most cases.

    You should try the following:

    for (var key:* in dic) trace(getQualifiedClassName(key));//will give you 'String'
    

    this behaviour is true for Array and Object as well.

    As a rule of thumb: int stays int and any other key is converted to its string representation (including boolean and float values, as well as null and undefined).

    The Dictionary class is different in that it does not convert non-primitive objects to String, but uses them as a key directly. They way of handling all other values is “inherited” Object if you will.

    Basically, an Object consists of 2 hashes, one for string and one for integer keys. And the Dictionary adds another hash, probably simply using the objects memory address as integer key.

    edit: Not really an answer to the actual question, but a point I want to explain in detail, in response to Triynko’s comment:

    Hacky? You mean, making it work in a
    way it’s not designed to work? Well…
    since it’s not designed to handle
    64-bit integers, of course it’s a
    hack. But 64-bits is 64-bits, whether
    they’re interpretted as an integer or
    floating point.

    Using 64 Bit floats to represent 64 Bit ints is already a bad idea, because semantically, it’s completely wrong (you can usually expect problems to arise from this kind of misuse).

    But then using their String representation as key (which implicetely happens if you use a float as key) is plain suicide:

    var f1:Number = 1000000000000003000000000.0;
    var f2:Number = 1000000000000002000000000.0;
    trace(f1 == f2);//false
    trace(String(f1) == String(f2));//true ... kabooooom
    

    You will have a hard time determining, when 2 64 bit ints will collide, since the prequisite is that the string representation of their values interpreted as floats must be equal. Also, different player versions might have different string conversion of floats, as may alternative runtimes such as LightSpark. I really wouldn’t wanna rely on this. This yields the kind of bugs that seem to come out of nowhere, when there’s enough data to cause collision. And you will not enjoy tracking them down.

    Also, float keys perform worse, since they have to be converted to strings before used for hash look up. If you are really so concerned about size, then you’ll have to transmit the data as 64 bit int and convert it to a hex String on flash side only.
    None the less, I would point out, that many people are extremely happy using XML or JSON, which has far worse overheads.

    Bandwidth and any other hardware resources are cheap. Developement is expensive. You should write your apps to be maintainable and robust, otherwise they cost you more in the long run.

    greetz
    back2dos

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

Sidebar

Related Questions

I have a code as below import flash.media.Sound; import flash.media.SoundChannel; flash.system.Security.allowDomain(*); var request:URLRequest =
Porting a pure Flash/AS3 application to Flex 4.5 this code: <fx:Script> <![CDATA[ import mx.events.SliderEvent;
Below is a basic code bit in as3 flash.A simple video streaming example using
I have an FLA done in Flash 10, and some AS3 code that manipulates
I am new to AS3. When learning AS3, I get the below code from
In my as3 code using Flash cs3, everything works fine without any document class.
When I attempt to create a new flash list component from my as3 file
Can someone post an example of as3 code (specifically event listener included) that would
I've done most of my code in as3, working from either document class or
Does anybody have any experience with as3-spod? I downloaded the source code from github

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.