Tony,
Yes, we absolutely intend to continue supporting
extending MXML with MXML, with the constraint that only one set of children be
specified anywhere in the chain of derived components or the component instantiation.
What you’re seeing is a bug in beta
2 – the framework incorrectly raises the “multiple sets of children
in base and derived components” error in cases where the superclass (A.mxml
in your example) in fact has no children.
This will be fixed for beta 3; the
workaround in beta 2 is to insert the following <Script/> code into the
superclass, e.g. A.mxml:
<mx:Script>
/**
*
This namespace is used for undocumented APIs -- usually implementation
*
details -- which can't be private because they need to visible
*
to other classes.
*
APIs in this namespace are completely unsupported and are likely to
*
change in future versions of Flex.
*/
namespace
mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
override
mx_internal function
setDocumentDescriptor(desc:mx.core.UIComponentDescriptor):void
{
if
(mx_internal::_documentDescriptor &&
mx_internal::_documentDescriptor.properties.childDescriptors)
{
if
(desc.properties.childDescriptors)
{
throw
new Error("Multiple sets of visual children have been specified for this
component (base component definition and derived component definition).");
}
}
else
{
mx_internal::_documentDescriptor
= desc;
mx_internal::_documentDescriptor.document
= this;
}
}
</mx:Script>
Basil
From:
[email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tony Pujals
Sent: Wednesday, March 22, 2006
6:02 PM
To: [email protected]
Subject: [flexcoders] Extending
MXML components (change from 1.5 to 2)
In Flex 1.5,
you could create an MXML component and then extend it with another custom
component. For example, this would work:
A.mxml
<?xml
version="1.0" encoding="utf-8"?>
<mx:Canvas
xmlns:mx="http://www.adobe.com/2006/mxml">
</mx:Canvas>
B.mxml
<A
xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Button label="Hello"
click="mx.controls.Alert.show('Hello')" />
</A>
Test.mxml
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml">
<B />
</mx:Application>
How was this
useful? Well, for example, for an HTML page editor, we had an Element.mxml
component subclassed by ImageElement.mxml and TextElement.mxml.
This does not
work with any of the Flex 2 alpha/betas. Flash 8.5 displays this diagnostic:
Error:
Multiple sets of visual children have been specified for this component (base
component definition and derived component definition)
at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::setDocumentDescriptor()
at A/initialize()
at B/initialize()
at
mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::rawChildAdded()
at mx.core::UIComponent/addChildAt()
at mx.core::Container/addChild()
at mx.core::Container/createComponentFromDescriptor()
at mx.core::Container/createComponentsFromDescriptors()
at mx.core::Application/createComponentsFromDescriptors()
at mx.core::Container/mx.core:Container::createChildren()
at mx.core::UIComponent/initialize()
at mx.core::Container/initialize()
at mx.core::Application/initialize()
at flextest/initialize()
at mx.managers::SystemManager/::initializeChild()
at mx.managers::SystemManager/::initializeTopLevelWindow()
at mx.managers::SystemManager/::frameEndHandler()
It’s
not that the error message isn’t clear, per se, but since this is
different behavior, I’m curious …. Can you only extend mx
components but not you’re own, or this only possible with ActionScript
components and not mxml….?
Thanks,
Tony
tony pujals| senior engineer | Yahoo! SiteBuilder Express
p. 408.349.6284 | e. tonyp
* yahoo-inc * com | y!id tonypujals
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

