The opposite code in Flex

Why in Flex does the code behind the template use the ActionScript class as the base class instead of using the MXML component for this?
I mean, instead of extending our AS3 code one by one, why aren't we extending our MXML in the new AS3 class?

Using this approach seems more natural, since it is a real extension, we add code and functionality to our MXML database.
Using the code behind the template is a hack for OOP, every time we add a component to our MXML, we need to change our AS3 class, that is, if we modify a child element (MXML), we also need to change the parent element (AS3).

What is wrong with the opposite code ("code ahead"?)?

+3
source share
4 answers

The "Front Code" is a more natural extension and design of OOP, because we extend our MXML with functionality in AS3, and we do not need to change the parent every time our child changes.

But it has a limit, we cannot use binding in MXML, because now our MXML is our base class, and we have our vars / functions in the AS3 child class.
EDIT: Another problem with the code ahead is that you cannot see your “AS3 component” in development mode (not tested in FB4 +, maybe it works now). Read more about this in Mark Hughes's answer.

+1
source

Adobe Spark .

(-ish) ActionScript, SkinnableComponent SkinnableContainer, . MXML, , (, , - , ).

. , , , .

+2

- . AS3 Flex Builder 3. , . , - : http://www.rogue-development.com/blog2/2007/03/code-in-front/

Flash Builder 4. , , - , . - .

MXML, MXML, .

. , , . (Skinning , )

+2

I think the reason for this is the inherited component architecture inherited from Flash, where you drag the black box component and most likely jinx the skin a bit at the color / shape / font level and cannot (cannot) touch how this works.

0
source

All Articles