The original question was about how to emulate that restriction, not get around it. Although the motivation for such escapes me!
On Fri, May 2, 2008 at 4:09 PM, Alex Harui <[EMAIL PROTECTED]> wrote: > You can't instanitate Menu from MXML either. > > > > Instead of extending Alert, just use a TitleWindow with your own logic in > it. > > > ------------------------------ > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Daniel Gold > *Sent:* Thursday, May 01, 2008 8:13 PM > *To:* flexcoders@yahoogroups.com > *Subject:* Re: [flexcoders] Re: Extending Alert > > > > This peaked my interested and I quickly flipped through the Alert class to > see what was going on. Nothing really caught my attention so it seems like > this is enforced by the MXML compiler. I verified this by adding an Alert in > AS without using the static show funciton. In a simple test application I > added a button that called this: > > var alert:Alert = new Alert(); > addChild(alert); > > An empty Alert window was added to the application. Seems kind of bizarre > the way this component works. Are there any other cases of flex components > extending UIComponent that aren't allowed to be instantiated through MXML? > > One thing you could do is follow their pattern of having a class with a > static show() function. If you don't mind building the entire component in > ActionScript that function could create a TitleWindow/Panel, apply the > styles, add the children you want, and add the container to the application > or specified parent. As long as the class doing this isn't a UIComponent > itself, noone will be able to add it to a container in MXML. > > On Thu, May 1, 2008 at 10:08 AM, climbfar <[EMAIL PROTECTED]> wrote: > > I believe this is a restriction brought on by the Adobe developers. > You cannot do this in MXML: > > <mx:Panel id="panel"> > <mx:Alert> > </mx:Alert> > </mx:Panel> > > If you try to compile, you will get this message: > > "Could not resolve <mx:Alert> to a component implementation." > > To instantiate an Alert in MXML the proper coding would be: > <mx:Panel id="panel"> > <mx:Button click="mx.controls.Alert.show('hello')"/> > </mx:Panel> > > Basically I would like to create a similar component that would be > used for configuring some task modally and presumably extending it > off the Alert or TitleWindow component. > > G'day Mike > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, Maciek > Sakrejda <[EMAIL PROTECTED]> > wrote: > > > > > > Why do you need to prevent usage through MXML? MXML is compiled > down to > > ActionScript, so it's essentially just syntactic sugar. That is, by > > preventing using your components through MXML, you are just > removing a > > convenient interface, and not restricting functionality. > > -- > > Maciek Sakrejda > > Truviso, Inc. > > http://www.truviso.com > > > > -----Original Message----- > > > From: climbfar <[EMAIL PROTECTED]> > > Reply-To: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com> > > To: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com> > > Subject: [flexcoders] Extending Alert > > Date: Thu, 01 May 2008 14:18:55 -0000 > > > > How do I extend the Alert class such that the new class cannot be > > created using MXML tags? Taking it a step further is it possible to > > create an ActionScript class extended from Panel that cannot be > > constructed using MXML tags? > > > > G'day Mike > > > > > > > -- "Therefore, send not to know For whom the bell tolls. It tolls for thee." :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]