PDA

View Full Version : This class only loads XML...what should it extend?



REEFˇ
August 17th, 2008, 06:38 PM
I have a class which allows the document class to say:

var mynewxml:XMLCLASS = new XMLCLASS("xmlfile.xml", newsTextField);

All that class does is load the file and put its contents into newsTextField. I have it currently extending Shape, to simplify it the most, I'm not sure what to extends to make Flash know its super simple and all it does is load an xml file and place the text.

*seems like extends Object keeps the filesize down the most. But I thought object was the biggest thing to inherit, and extending Shape adds 0.06KB to the size.

Krilnon
August 17th, 2008, 07:34 PM
Shape?? I don't see why XMLCLASS would need to be any sort of DisplayObject if the TextField is the visible element.

Any class that you make is a subclass of Object, whether you like it or not, so it is nonsensical to say that it is the biggest thing to inherit because you'll never know how big a class would be without being a child of Object. If you leave off the extends [SomeClass] part of the class declaration, Object will be the parent class. I recommend doing that unless you have a use for methods from any other class.

REEFˇ
August 17th, 2008, 07:41 PM
Yeah it doesnt have anything to do with any sort of DisplayObject, all it does really is return xml data, just have no clue what the extend it as to let Flash know its a simple class.

sekasi
August 17th, 2008, 07:45 PM
Don't extend anything.. There's really no point in this specific case.

You only want to have your classes extend other classes or abstract classes when you need to use their methods or properties. Alternatively implement their interface.

In this case, your class does nothing but to load data, so having it extend anything and add overhead is pointless :o

dail
August 17th, 2008, 10:34 PM
I'd say eventDispatcher, as you probably want to dispatch some kind of event when your XML has loaded etc..