4 Replies Latest reply on Feb 9, 2007 4:34 AM by Peter Lorent

    To Extend or Not to Extend

    Rothrock Level 5
      I'm doing so work with Hindi/Devanagari text. The problem with Flash and complex languages like this is two-fold. You can't embed the fonts, so you can't count on things looking right. And Flash doesn't seem to know to break words at the spaces instead of just in the middle of letters.

      So I need to make a custom TextField class. I can't decide if it should extend the regular class or if I should do a composition and just wrap an instance of a TextField in my class.

      I'm leaning toward composition. Anybody have any guidance or suggestions?
        • 1. Re: To Extend or Not to Extend
          Peter Lorent Level 2
          Why are you leaning towards composition?
          • 2. Re: To Extend or Not to Extend
            Rothrock Level 5
            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.
            • 3. Re: To Extend or Not to Extend
              Peter Lorent Level 2
              >>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.
              • 4. To Extend or Not to Extend
                Peter Lorent Level 2
                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....