PDA

View Full Version : MVC: Where do I keep my graphical assets?


unkulunkulu
08-26-2008, 12:40 PM
Hello everyone,

I'm coding an application that uses MVC architecture, but I can't figure out where I should keep my graphical assets. I have a single SWF file with several library items with Linkage identifiers and I load the SWF file at the very beginning of the app.

After I get the reference to the swf (MovieClip), I pass it to the main Application, which passes it along to View, which passes it to whichever of it's descendants need it. That's quite a lot of passing along...

I'm wondering if it would be better to keep it in a single Singleton class, so I could reference it from wherever I need it. Has anyone used another approach to this.

Any help is greatly appreciated.

swivelmaster
08-26-2008, 08:15 PM
Check this out, I found it very helpful:

http://www.rogue-development.com/blog2/2007/11/slow-flex-builder-compile-and-refresh-solution-modules/

It seems like a pain in the butt, but the module/interface method has worked really well for me. It adds some overhead for setup for each extra asset you'd like to reference, but it means your singletons work great and you rarely need to rebuild your asset module.

unkulunkulu
09-02-2008, 01:06 PM
Thanks!

I concluded the Singleton approach was the most versatile as well. I did it a bit differently from the examples you gave though. I ended up not embedding the graphics, but instead making a separate swf called graphics.swf, which contains all the graphical assets.

What I have is a separate GraphicManager singleton class a lot like what Marc has in the link you sent. I initialize it in Main class and then just call the assets when needed.