flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice Amsellem <maurice.amsel...@systar.com>
Subject RE: Strange behavior of Dictionary and dynamic class
Date Thu, 06 Dec 2012 18:49:04 GMT
Hi Alex,

Following your answer, I did some more testing with different versions of the SDK:

SDK 4.1 => problem occurs (key is trimmed)
SDK 4.6 => problem does not occur (key is not trimmed)
I didn't test with SDK 3.x.

So I believe it's a bug in SDK 4.1 that was fixed in 4.5.

Is it worth filing a JIRA for an error that only occurs on SDK 4.1 ?

Regards,

Maurice 

-----Message d'origine-----
De : Alex Harui [mailto:aharui@adobe.com] 
Envoyé : jeudi 6 décembre 2012 19:17
À : flex-users@incubator.apache.org
Objet : Re: Strange behavior of Dictionary and dynamic class

Like I said, I believe that "::" is the namespace delimiter.

It might still be a bug, so file a JIRA issue and we'll see what the Falcon compiler does
with it.


On 12/6/12 10:03 AM, "Maurice Amsellem" <maurice.amsellem@systar.com> wrote:

> Hi Alex,
> 
> I gave Dictionary as an example only, sorry if this created confusion,  
> as the issue actually exists mainly for Object and any dynamic 
> subclass, when setting a string key  (see code below).
> 
> Actually, I am not using Dictionary for storing String=> Object maps, 
> but my own dynamic subclass of Object.
> 
> The test below fails, and the debugger show that map contains one key "myKey"
> and not "myPrefix::myKey";
> 
>    [Test]
>     public function testObjectKey():void {
> 
>         var key: String = "myPrefix::myKey";
>         var map: Object = {};
>         map[key] = "myValue";
>         var result: Object = map[key];
>         Assert.assertNotNull( "key with :: should not be null", 
> result);
> 
>     }
> 
> Am I doing something wrong ?
> 
> Regards,
> 
> Maurice
> 
> -----Message d'origine-----
> De : Alex Harui [mailto:aharui@adobe.com] Envoyé : jeudi 6 décembre 
> 2012 18:21 À : flex-users@incubator.apache.org Objet : Re: Strange 
> behavior of Dictionary and dynamic class
> 
> Hi Maurice,
> 
> Strings should not be used as keys in Dictionary.
> 
> I believe that :: is a namespace delimiter.
> 
> HTH,
> -Alex
> 
> 
> On 12/6/12 5:43 AM, "Maurice Amsellem" <maurice.amsellem@systar.com> wrote:
> 
>> Hi,
>> 
>> I have noticed  a strange behavior regarding the way dynamic classes, 
>> including Dictionary and Object manage keys:
>> 
>> if you are using a String key and the key includes "::", then 
>> everything before the "::"will be stripped from the key.
>> Example:
>> 
>> var dic: Object ;
>> dic ["prefix::ABCD"] = "SomeValue".
>> 
>> The Object will now contain:
>> "ABCD" => "SomeValue";
>> Instead of:
>> "prefix::ABCD" =>"SomeValue";
>> 
>> My intuition is that FlashPlayer does this to store Class members that are in
>> a different namespace,  eg.    DataGrid.mx_internal::sortDirection,
>> so that the namespace is trimmed from the variable name.
>> 
>> "::" is also used as the separator between namespace and Class or 
>> variable name in Qualified Names, as returned by
>> getQualifiedClassName()
>> 
>> So if you use a key that includes a qualified name, obtained from
>> getQualifiedClassName() or a variant, then you must replace "::" with 
>> something else, before using it as a key.
>> 
>> var key : String = "prefix::ABCD";
>> var safeKey: String = key.replace("::","."); dic[safeKey] = value;
>> 
>> Note:  Adobe documentation subtely suggests this limitation in the 
>> flah.utils.Dictionary class online help:
>> 
>> Note: You cannot use a QName object as a Dictionary key.
>> 
>> Albeit it's true for any dynamic class, and even if the key is a 
>> String including "::" .
>> 
>> http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl
>> a
>> sh/utils
>> /Dictionary.html
>> 
>> This limitation is probably well known of Flexers, but I thought it 
>> was worth sharing with the community.
>> 
>> Regards,
>> 
>> Maurice Amsellem
> 
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
> 

--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Mime
View raw message