PureMVC Skeleton for ActionScript projects

I had previously done a PureMVC skeleton for Flash websites and applications, meaning that you would use the Flash IDE compiler to compile your project. Lately I have been doing more and more ActionScript projects (compiled using the Flex compiler but not using the Flex framework) because it permits the separation of big FLAs into smaller ones thus facilitating working in team. But I had no template/skeleton to start with until now.

So here it is:

PureMVC ActionScript Project Skeleton

It still uses an external preloader and I added a local Boolean so that the application knows your are testing locally and not on the sever (useful when making server call). One of the major change is the inclusion of the SharedAssetLibrary. Basically this emulate having one FLA with all graphics and MovieClip, but you actually can have multiple FLAs. When you want to add something to the SharedAssetLibrary you first add it to a FLA, set it to Export for ActionScript and then compile it to the swf folder. Then you can add it in the SharedAssetLibrary using the embed statment:

//BackgroundAsset being the name you gave it in the library
[Embed(source="../../../swf/Background.swf", symbol="BackgroundAssets")]
public var BackgroundAssets:Class;

Now if you want to use this in any of your views, first import SharedAssetLibrary and than you can use it like this:

var BackgroundAssets:Class = SharedAssetsLibrary.getInstance().getAsset("BackgroundAssets");
var assets:* = new BackgroundAssets();

I included a FlashDevelop project file in there, but you can just delete it if you use Flash Builder.

Using a skeleton greatly reduce the setup time of a project, so I hope this will help you. I want to look into doing a skeleton for Flex Application, because I don’t like the skeleton that is available on the PureMVC website.

, , , ,

  1. #1 by flashforg - July 19th, 2009 at 04:21

    Now if you want to use this in any of your views, first import SharedAssetLibrary and than you can use it like this:


  2. #2 by zedia.net - July 20th, 2009 at 10:52

    @ flashforg
    Since you don’t have access to the flash library directly in an ActionScript project, you have to use the Embed meta tag (Flex way) to import symbols from SWF.

    Now what is a problem with the Embed tag is that the path is relative to the class you are using so it keeps changing. Having a SharedAssetsLibrary class makes this easier by having all paths the same.

  3. #3 by Cameron - August 18th, 2009 at 05:06

    You can also use paths relative to the root of your project, e.g.

    [Embed(source="/../assets/flas/logo.swf", symbol='LogoEmbed')]

  4. #4 by cole - January 20th, 2010 at 13:59

    how would i access assets inside the clip i am embedding?


    the following does not work.
    assets.myMovieClip.alpha = 0;


  5. #5 by jones - June 8th, 2010 at 01:11

    This might be a stupid question but how do I import this into Flash Builder?

  6. #6 by mack - January 17th, 2011 at 05:20

    i reach at the pure mvc model . Now i did not know that how the data is passed in or out of the proxy class.
    Can you explain me about the proxy clss in detail.

(will not be published)
Subscribe to comments feed

Parse error: syntax error, unexpected ';' in /homepages/25/d169645162/htdocs/wp-content/themes/fusion/footer.php on line 13