This content has been marked as final. Show 4 replies
Why are you leaning towards composition?
Frankly because I understand it better. Is there a reason not to?
Also I will need many of the methods of the TextField class and also some of the TextFormat class, but not all of them. Since you can't embed or change fonts, etc. I thought it might be cleaner to sort of combine that all together and only provide methods that won't get me in trouble.
>>Is there a reason not to?
Well, there is much to say about inheritance and personally I try to avoid it. Here are some points to consider (random order btw).
1. Using inheritance generally means faster execution of the code
2. If you want to take advantage of polymorphism, consider inheritance
3. If the object just needs (some of) the services of another class, consider composition
4. If your object behaves very much like an existing class, consider inheritance
5. Changing code in inheritance often requires more work than code that uses composition.
Since you won't be needing all functionality of the TextField Class, my choice would be composition too.
Ding ding ding. One other thing to consider: you cannot extend the TextField Class. You create instances using MovieClip.createTextField() and that only allows you to create the normal textfield....