|
Accueil - Using PureMVC Loadup utility with Flash IDE
Created :
Last modified : Using PureMVC Loadup utility with Flash IDE![]() The Loadup library is a PureMVC utility intended to add support for Lazy Loading in PureMVC applications. It can also be used to load assets and report progress during loading. I recently had to use the assetloader package of the PureMVC Loadup utility in a pure ActionScript project. When I finished to integrate it in my project, I realized that my application took an unwanted 120KB file size. After a little exploration, I found some direct references to As you may know, When I reported this problem on the PureMVC forums some users asked for a solution, I promised to blog mine. So here it is. Thanks to Philip Sexton, its author, the Loadup utility is pretty well made. It is really easy to change the default asset classes to remove any Flex dependencies. It never requires to modify the utility itself, only its implementation. The Here is main changes brought by protected function defaultMap():Object { var obj :Object = new Object(); obj[ Loadup.IMAGE_ASSET_TYPE ] = [ AssetOfTypeFlashImage, AssetLoadByLoader ]; obj[ Loadup.SWF_ASSET_TYPE ] = [ AssetOfTypeFlashSwf, AssetLoadByLoader ]; obj[ Loadup.TEXT_ASSET_TYPE ] = [ AssetOfTypeFlashText, AssetLoadByURLLoader ]; return obj; } Where we had this in the original protected function defaultMap():Object { var obj :Object = new Object(); obj[ Loadup.IMAGE_ASSET_TYPE ] = [ AssetOfTypeImage, AssetLoadByLoader ]; obj[ Loadup.SWF_ASSET_TYPE ] = [ AssetOfTypeSwf, AssetLoadByLoader ]; obj[ Loadup.TEXT_ASSET_TYPE ] = [ AssetOfTypeText, AssetLoadByURLLoader ]; return obj; } And, as an example, the newly created public class AssetOfTypeFlashImage extends AssetBase implements IAsset { public function AssetOfTypeFlashImage( url:String ) { super(url); } public function get type():String { return Loadup.IMAGE_ASSET_TYPE; } public function get bitmap():Bitmap { return data as Bitmap; } } And the original public class AssetOfTypeImage extends AssetBase implements IAssetForFlex { private var _uiComponent :UIComponent; public function AssetOfTypeImage( url :String ) { super( url ); } public function get type() :String { return Loadup.IMAGE_ASSET_TYPE; } public function get uiComponent() :UIComponent { if ( ! data ) return null; if ( ! _uiComponent ) { var img :Image = new Image(); img.load( data); _uiComponent = img; } return _uiComponent; } } Now, I'm sure that we can update the Loadup utility to Loadup 2.1 to extract the default map from the AssetTypeMap to a class. Or probably a better idea to create a different flex and a flash package to have default assets and asset type map for each. You can launch the live demo, download or browse the sources. Note that I use a specific configuration that allows to easily compile the same project in Flash Builder and Flash CS3. Don't use this configuration in your real Flash Builder projects, the SWC compiled from Flash IDE and used for graphical assets in Flash Builder also contains the whole application code. You better have to generate a SWC from Flash with graphical assets only. Also note that as I use Flash CS3 to compile the project, you will find lib source instead of SWC as Flash CS3 compiler is unable to use SWCs. Comments[…] This post was Twitted by AS3LibHash […] […] Likes HTC’s 2010 Android lineup revealed – Android and Me 2 Likes Tekool.net - Développeur Flash - Using PureMVC Loadup utility with Flash IDE Développeur Flash Actionscript sur FlashDevelop ou Eclipse. Blog traitant de projets […] Leave a comment |
||
| wordpress rss rss français rss english xhtml 1.1 css 2.0 wdg |
[…] Tekool.net - Développeur Flash - Using PureMVC Loadup utility with Flash IDE www.tekool.net/blog/2009/12/06/using-puremvc-loadup-utility-with-flash-ide – view page – cached Développeur Flash Actionscript sur FlashDevelop ou Eclipse. Blog traitant de projets personnels, Flash, Flex, Apollo, PHP, Javascript, Ajax, C#, POO. […]