Additions of the Number Data Type

I’m trying to get the sum of two number values in an XML file, so I’m doing this:

	_root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
	_root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'

	_root.bar_y= _root.gallery_height+_root.spacing;
	trace(_root.bar_y); //outputs 20020

The answer is supposed to be 220, but it comes out at as 20020 because the interpreter treats then as strings.

I can fix the problem by casting the type using the Number() method this way:


	_root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
	_root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'

	_root.bar_y= Number(_root.gallery_height)+Number(_root.spacing);
	trace(_root.bar_y); //outputs 220

This works fine, but is it the right way of doing it? Why is Flash treating my numbers as strings?