Toon Van de Putte wrote:
I was wondering if the following two lines of code are just different ways
of doing the same thing:

var myVar = new Number();
myVar ="0";

Using new Number is... silly. The Number-object is quite useless and can't be used for anything, that a regular number can't. Use normal numbers and use numbers:

var myVar:Number = 0;

Or casting:

var myVar:Number = Number("0");

Or parsing:

var myVar:Number = parseInt("0");

The fact that you set a variable to something, and then set it to something else does not change anything. Sometimes you see people do:

var foo = new Array();
foo = bar.slice();

Why set it to a new arary, when you set it to something else (and deletes the old reference) anyway. ActionScript does not work this way. Set your variable, to what it is supposed to be.

To sum up: Assignment does not look at the current value at all - it deletes the current value and assigns the new one.

--
Morten Barklund - Information Architect - Shockwaved
Gothersgade 49, 4th floor - DK-1123 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to