Ok so I have been working on getting pre init code to run on an
extension of the current application class for the past 2 days. Going
through the chain of inheritance and trying to wrap my head around it.
Here are my issues:
1) I need a way to preload content into the application. As of now if
I extend Application directly there are not hooks to inject code
before all the Component -> Container logic fires. This is not so bad
but if my Main class is MXML (extending my implementation of
Application) my configuration logic fires after any components get
instantiated. So this is a little bit of a problem since Component is
not set up in a modular enough way to inject "preinit" code and
manually resume the built in initialization process. If this does
exists I am missing it somewhere.
2) There is no hook for when the application is ready. I have added my
own which ties into my own configuration logic but there is currently
no way to do this in any MXML class similar to how you can in Flex.
3) I am fine with not making my main class MXML (since I can't force
my own configuration files to load in first) so is this the intended
solution? I am still wrapping my head around best practices for Reflex
and MXML classes since my exposure to Flex has been very little.
4) Finally going through the chain of inheritance of Application ->
Component -> Container I found it extends MovieClip? Why not make
this extend Sprite? I don't see any advantages we would gain over
using MovieClip but if I am wrong I would love to know why.
Thanks for listing,
Jesse
--
To unsubscribe, reply using "remove me" as the subject.
We could add a preInit event to be dispatched in the constructor of Application. This would make it easy to add stuff in MXML to that event. There is also currently an init method which can be overridden when a component is added to the stage (creationComplete) and I believe an init event is fired then too. This is also when the application is complete.
I recently spent some time understanding the [Frame] meta tag and implemented a preloader hereBut, turns out the -frame compiler option works much better since it doesn't force a dependency on IFlexModuleFactory and results in much cleaner code.
Though, this does bring up a point I neglected to mention previously
about the ReflexApplicationLoader:
We could support the [Mixin] tag, (more here:
http://nondocs.blogspot.com/2007/04/metadatamixin.html ). Basically if
you write a class with [Mixin] metadata, create a static init function
which accepts the root MC as its only parameter, we can do some static
initialization before the Application is created and added to the
stage. FlashBuilder generates a list of "mixins" (classes it knows
about with the [Mixin] metadata tag) that the Flex SystemManager calls
the init method on them before it creates the Application. Here's the
code that we could change in the RAL: http://gist.github.com/359366
Let me know if it's something that interests you guys.
Paul
> I have a few
> suggestions we could talk about sometime. Specifically refactoring to a
> factory base-class that could work on a 1st, 2nd, 3rd frame and so on.
True that, it could be totally useful.
> Extending this class with an exposed continue() API or something would make
> it easy to create custom initialization frames where any type of
> asynchronous initialization would be possible. I got a little carried away
> daisy-chaining factory classes
A few things I'm not sure about is 1. the order in which the frames
are placed, and 2. who will be set as the root mc.
The Frame metadata on the [Reflex] Application class does something
very different than Frame metadata on your actual (mxml or AS) App's
Application class. If it's on the Reflex Application, FB generates/
compiles in the "SystemManager" for you. If it's on your App's
application class, I know it doesn't generate a subclass, instead it
uses the actual implementation you specify, but it does compile it in
on a frame... just not sure of the order.
> The mixin tag might have some merit too
I could see a mixin class that initializes styles on the root before
the Application is created/added, and possibly inherit them when he's
added to the stage. Not too familiar with Jac's styles implementation
yet, but it's possible. What about applying Layouts to the root MC
this way? I'm sure there are some legitimate uses for it.
Paul
> >http://nondocs.blogspot.com/2007/04/metadatamixin.html). Basically if
Rick
On Apr 7, 2:50 pm, Tyler Wright <xty...@gmail.com> wrote:
> Jesse,
>
> Because of the way MXML is compiled in the FlexSDK *all* of the objects are
> created in one pass. This means we can only delay instantiation where
> children are assigned dynamically, such as with a skin-lookup via the CSS.
> It would be possible to have a pre-init hook fire before children are added
> to the display-list, possibly before the children are even created, but no
> way to halt the process and then manually resume later.
>
> There's another option where you could load pre-initialization stuff before
> the Application class is instantiated. We plan on taking full advantage of
> the [Frame] meta-tag that allows 2 or more frames to load the application in
> pieces (Flex uses a two-frame system). I finally got my hands dirty with the
> system and would love to write up an article on modularity in Reflex, but
> don't have the time to fully document it at the moment.
>
> If you describe the kind of pre-init things you're trying to accomplish it
> would help determine if there's another approach that would be a better fit.
>
> Tyler
>
> > To unsubscribe, reply using "remove me" as the subject.- Hide quoted text -
>
> - Show quoted text -
Tyler, aren't there cases of deferred/lazy instantiation in certain
containers? I was under the impression that containers such as the
Tab-* components behaved this way, thus the reason for the
creationPolicy property.
Sorry, I've been slacking on this the last two weeks, deadlines have
reared their ugly heads. In addition to the SetProperty functionality,
I've got the includeIn and excludeFrom working locally and I should be
posting it in the next week or so.
Paul