No, there were no visual children in Base--just an empty canvas.  I tried what you suggested and created Base using ActionScript only and that worked just fine.  Thanks.  However, it does bring up the question: Why doesn't the MXML approach work?  Is it a bug?

On 12/30/05, Matt Chotin <[EMAIL PROTECTED]> wrote:

Did you put any visual children in Base?  If you did it's not going to work because you can't have declared children in a parent component and subcomponent (though we may describe how to simulate that in some of our docs with other features).

 

You can try rewriting Base.mxml to be Base.as if there weren't visual children

 

Public class Base extends Canvas

{

  //declare properties and methods

}

 

Matt

 


From: [email protected] [mailto: [email protected]] On Behalf Of Jason Y. Kwong
Sent: Friday, December 30, 2005 10:44 AM
To: Flashcoders mailing list; [email protected]
Subject: [flexcoders] Flex 2: Component inheritance?

 

I'm relatively new to Flex 2 and what I'm trying to do is to create a set of custom MXML components that share the same AS base class.  So I start with the base component, an empty container to which I add properties/methods via AS.  Call it Base.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">
<mx:Script source="Base_inc.as"/>   <!-- Declare base properties/methods -->
</mx:Canvas>

Then I create a component based on Base.  I add a Button and a TextInput.  Call it ComponentA.mxml :

<?xml version="1.0" encoding="utf-8"?>
<Base xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">
    <mx:Script source="ComponentA_inc.as"/>   <!-- Component-specific code -->
    <mx:Button x="5" y="41" label="Button"/>
    <mx:TextInput x="2" y="12" text="hello" id="MyText"/>
</Base>

Then I add ComponentA to an application.  Everything looks fine in the design view.  However, when the app is run, the controls added by ComponentA do not show up.  I put in a creationComplete handler for ComponentA and traced the value of "MyText" and it came out null, so it looks like it never got created.

Am I missing something?  If this isn't how you do component inheritance, then how can it be done while still taking advantage of the easy layout offered by MXML?




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to