« FABridge: Warn on flex application exit
» Deep Object Copy

ActionScript, Bugs, Flex 2

Constant XML not so constant?

25.10.07 | Comment?

It seems that the constants behave strangely in Flex.

Here is why:

public const X:String = "X";
public const Y:int = 101;
public const NotSoConstant:XML = ...some random xml...

Now here comes the fun part:

var x:string = X;
x = "aaa";
trace(X + ":" + x); // X:aaa
var y:int = Y;
y = 10;
trace(Y +":" + y); //101:10
var constantOrNot:XML = NotSoConstant;
constantOrNot = ...another xml...

Now you would think that constantOrNot will be different from NotSoConstant? You would be wrong. It seems that in the cases of XML objects the initial setup of the constantOrNot is done by using a reference pointer. So if you modify the constantOrNot it will also modify the constant it was used to set it up.

Popularity: 21%

Share and Enjoy:
  • Technorati
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Reddit
  • Digg
  • Furl
  • co.mments
  • blogmarks
  • Slashdot
  • DZone
  • Taggly
  • YahooMyWeb
  • connotea
  • Webride




Tags: , , ,

This post was written by Virgil Cristea

Views: 425

related

popular

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

:

:


« FABridge: Warn on flex application exit
» Deep Object Copy