flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Loading Flex Themes
Date Tue, 30 Oct 2012 16:16:21 GMT
Whether you load themes via modules or StyleManager.loadStyleDeclaration
(which is also effectively loading a module), the load is asynchronous and
could take more than a couple of frames in which case the app will start to
apply the default theme to the components, then that work will be re-done
once the module finishes loading, and if it takes too long, you'll see the
app in the default theme, then it will switch to the new theme.

One thing you could try (easier with Flex 4) is declare two states in your
app (e.g "loadingTheme" and "final").  The only components in the
"loadingTheme" state is some generic UI like a label or progress bar saying
the app is initializing.  If you want to get fancy, I suppose you could put
up a generic login box, or some advertisement or help about the app, but the
point is that the visuals will have to be in the default theme.

Then when the theme is loaded, you can switch to the final state which will
cause all of the actual components to get initialized in the desired theme.


On 10/30/12 6:54 AM, "Cortlandt Winters" <cort@cortwinters.net> wrote:

> Hi Harbs,
> I had to do this with a Flex3 app and I think the same process would work
> for you conceptually in Flex4 though modules are different in Flex4 (and
> more reliable)
> The first part is to use the preinitialize event in your main app to load
> your config file or make the server call to get the right theme to load.
> The real work is in doing the work of separating your themes into  modules
> that you can load dynamically. You need to define an interface that
> contains the names of all your graphics, then create concrete classes that
> implement the interface by embedding different graphics for your specific
> themes.
> When your preinitialize event returns, you load the correct module for the
> theme you'd like to use. Everywhere in your code  you reference the names
> of the graphics that are defined in the interface so it works rather
> nicely.
> The only annoying thing is that whenever you add a new graphic to your app,
> you need to add a version for each theme. For this reason, you might want
> to create a "Default" theme class that has a basic, default theme and
> subclass it for the themes themselves with their differences. That way
> things like icons that are shared amongst all themes are easier to manage
> and maintain.
> HTH,
> -Cort
> On Tue, Oct 30, 2012 at 3:20 AM, Harbs <harbs.lists@gmail.com> wrote:
>> I have a (Flex 4) app in which I need to load different theming based on
>> some choice made before the app is loaded at runtime. I know I can set the
>> theming using styleManager.loadStyleDeclaration() and specify the correct
>> theme using Flashvars, but I'm trying to figure out how to load the correct
>> theme initially. I don't want the app to open with one appearance and then
>> switch to another. To further complicate matters, I'd like to only load the
>> theme that was specified, as the number of themes can become quite large
>> and I don't want to load extra assets unnecessarily.
>> Ideas?
>> Harbs

Alex Harui
Flex SDK Team
Adobe Systems, Inc.

View raw message