Look into FTML for that, it's already built in native for Flex... and much
more.
On Jun 12, 2012 9:27 AM, "Dirk Eismann" <bort...@googlemail.com> wrote:

> I'm currently experimenting on how to improve resource management in
> future Apache Flex versions.
>
> It all started when I wanted to mimic the Android IDE (ADT) behavior
> where ADT automatically creates a class R with static accessors for
> project resources. E.g. a default Android project has a /src and a
> /res folder. If you put a foo.jpg into the /res/drawable folder, the
> ADT creates R.drawable.foo that can be referred to in your code (where
> foo is actually a int that's used for resource loading at runtime,
> more info here [1])
>
> So I jumped in and created a plugin for Eclipse / Flash Builder that
> does the same by autogenerating a R.as class with static fields that
> are used to [Embed] image assets. As soon as you drop images into
> /res/images inside of a FB project, the R.as class gets updated etc.
> This happens before the mxmlc compiler starts a compilation run, so
> you can do this in your code
>
> <s:Image source="{R.images.foo}"/>
>
> This works pretty nicely, although as of now it's only working in FB /
> Eclipse, not with CLI builds (yet) [2]
>
> The next thing on my list was to improve ResourceBundle / i18n
> handling a bit. I'm too tired to use ResourceManager.getInstance or
> resourceManager.getString("foo", "bar") all the way which is annoying
> to type and error prone. Would be much nicer to have code hinting here
> as well. Ideally, I'd like to do
>
>  <s:Label text="{R.bundles.myBundle.foo}"/>
>
> which would get the value of the key "foo" from ResourceBundle
> "myBundle". Another way would be to have a class B (for Bundles) which
> is even less typing
>
>  <s:Label text="{B.myBundle.foo}"/>
>
> or something like this.The general idea is to avoid too much typing
> and taking advantage of what an IDE offers you in terms of code
> hinting.
>
> The nice side effect of this "less code to type" approach is that you
> get "less errors that will happen" as well since all asset / resource
> accesses are checked by the compiler.
>
> Currently I have a few ideas and things I would like to implement:
>
> 1) envision how a default project layout for a Flex project could look
> like. As of now a default project has a /src folder. Maybe we can
> agree that it's a good idea to put place assets into an /assets or
> /resources folder. This would be the default path that is used for
> automatic asset / bundle transformation and code generation
>
> 2) create a compiler extension for mxmlc or a patched version of the
> flex2.compiler.i18n.I18nCompiler that automatically generates / emits
> code for the R class and modifying the code that gets generated for
> the mx.resource.ResourceBundle sublasses without breaking backwards
> compatibility (so you can still do @Resource or
> resourceManager.getString())
>
> 3) create a Ecipse / FB plugin that uses the "rules" from 1) and the
> compiler extension from 2) to streamline this in the IDE (as of now I
> am an FB / Eclipse user so I can only provide Elcipse plugin know-how,
> I have not yet done anything with IntelliJ or any other Flex IDE)
>
> So... what do you think? I would also like to know what other people
> have in mind concerning asset / resource bundle management, maybe we
> can team up?
>
> Cheers,
> Dirk.
>
> [1] http://developer.android.com/guide/topics/resources/index.html
> [2] https://plus.google.com/u/0/111304077092175055051/posts/St8TkR4DFLY
>

Reply via email to