Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/ab29539ab9.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, Bugs, Flex 2

Constant XML not so constant?

Virgil Cristea | 25.10.07 | Comment?

Google Buzz

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.

Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites




Tags: , , ,

This post was written by Virgil Cristea

Views: 2166

related

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> <pre lang="" line="" escaped="">

:

:


«
»