I suppose it is technically possible, but IMO, the compiler should not be generating code. Right now, it mostly generates data, leaving it up to the framework to run code based on the data. Also, the compiler currently does not think about the CSS it converts to data.
However, you reminded me of another solution. The equivalent of what you are asking for is for a bead or mixin to inject beads into the compiler's MXML data stream. The children of an MXML view are encoded into an array of data. There should be way to alter that array before it is interpreted by MXMLDataInterpreter (or, monkey patch MXMLDataInterpreter to inject the beads). It's been on my to-do list to create utility functions to manipulate the data array, but I haven't found time. Maybe another volunteer can do it. We could use these functions someday to swap in mocks and other testing beads for automated testing. All of these ideas will take time to implement. It should be much easier to subclass the layout you use and have them check for visible or create a wrapper that does the checking. My 2 cents, -Alex On 8/7/17, 2:46 PM, "Harbs" <harbs.li...@gmail.com> wrote: >Why can’t the compiler use the CSS declarations to add beads to a beads >array in MXML? > >I think it’s an acceptable compromise that injectable beads in CSS would >only work for MXML files. > >> On Aug 8, 2017, at 12:32 AM, Alex Harui <aha...@adobe.com.INVALID> >>wrote: >> >> All of the implementations I can think of add just-in-case code to check >> for a CSS property and/or check for an array. I suppose you could write >> some code that watches for changes to the DOM and adds a bead as things >> get added to the DOM. >> >> In your specific example, you want to customize layout and you can >>already >> do that in CSS. >> >> My 2 cents, >> -Alex >> >> On 8/7/17, 2:14 PM, "Harbs" <harbs.li...@gmail.com> wrote: >> >>> Yeah. But we really should have a way to declare beads that are >>>injected. >>> >>> Since we are already using CSS files to declare beads of specific >>>types, >>> maybe we can abuse CSS a bit more and allow declaring an array of beads >>> there? >>> >>> Either way, I think the code which delays layout of hidden elements >>>blows >>> up layout in subtle ways. I’m reverting that for now. Sometime when I >>> have the cycles maybe I’ll look at this again. >>> >>>> On Aug 8, 2017, at 12:08 AM, Alex Harui <aha...@adobe.com.INVALID> >>>> wrote: >>>> >>>> I hear you, but IMO, that's PAYG. Otherwise we would keep adding >>>>little >>>> bits of "just-in-case" code and end up with the same problems as >>>>regular >>>> Flex. >>>> >>>> UIBase knows to look for a model, view and controller. >>>> Container also looks for Layout. >>>> >>>> We don't want just-in-case code looking for other things. It would be >>>> great to find a way to use composition to inject another bead. I >>>> suppose >>>> you could write a custom View that automatically adds the bead you >>>>want. >>>> Or you can replace the layout with layouts that know how to not layout >>>> when not visible or wrap layouts with code that does a visible check. >>>> IMO, this last bit is the actual implementation you should choose. >>>> >>>> My 2 cents, >>>> -Alex >>>> >>>> On 8/7/17, 2:01 PM, "Harbs" <harbs.li...@gmail.com> wrote: >>>> >>>>> I actually just tried that, and it all blew up. I'll probably figure >>>>> out >>>>> why soon... >>>>> >>>>> It feels broken that I have to create my own Container just to get >>>>> layout >>>>> to happen when it becomes visible. >>>>> >>>>>> On Aug 7, 2017, at 11:55 PM, Alex Harui <aha...@adobe.com.INVALID> >>>>>> wrote: >>>>>> >>>>>> IMO, you should create a different Container (probably a cheap >>>>>> subclass >>>>>> of >>>>>> Container) and apply the bead in the constructor or fetch it from >>>>>>CSS >>>>>> in >>>>>> addedtoParent(). >>>>>> >>>>>> -Alex >>>>>> >>>>>> >>>>>> On 8/7/17, 1:12 PM, "Harbs" <harbs.li...@gmail.com> wrote: >>>>>> >>>>>>> I would like to apply a bead (LayoutOnShow) to every Container in >>>>>>>my >>>>>>> app. >>>>>>> I know I can subclass Container and add the bead using AS (or >>>>>>>mxml), >>>>>>> but >>>>>>> I’d like to keep my mxml markup and just inject the bead. I think I >>>>>>> want >>>>>>> to use CSS to do that, but I cannot figure out how to specify a >>>>>>>bead >>>>>>> which is not one of the accepted interfaces in CSS. >>>>>>> >>>>>>> Is there something I’m missing? Ideas on how to accomplish this? >>>>>>> >>>>>>> Harbs >>>>>> >>>>> >>>> >>> >> >