Jump to content
Search Community

Markavian

Members
  • Posts

    6
  • Joined

  • Last visited

Markavian's Achievements

0

Reputation

  1. Both methods call the internal method _dump(1, LoaderStatus.READY); - so they're doing the same thing. (See LoaderCore.as line 170, and line 273)
  2. In your QueueProgress(event:LoaderEvent):void method, instead of: var perc:Number = Math.abs(event.target.bytesLoaded / event.target.bytesTotal) * 100; I think you can use the currentTarget property: var perc:Number = Math.abs(event.currentTarget.bytesLoaded / event.currentTarget.bytesTotal) * 100; But you will probably need some conditional logic code to work out the switch between overall progress and individual progress. Edit: You can also use the currentTarget.progress property, which is "a value between 0 and 1 indicating the overall progress of the loader."
  3. I imagine creating a single XMLLoader and calling load with no cache on, and set flushContent to true: // load(flushContent:Boolean = false):void xmlLoader.load(true); // to flush previous content That way you create one XMLLoader object, and reuse it for the duration of the application. Should create the smallest memory footprint.
  4. Thanks for giving it some consideration- you know how your classes work a lot better then I do. My custom image loader / image holder class has a preloader system that checks for existing URLs being loaded, but doesn't work with the LoaderMax. Is that not something that could be written into the LoaderMax framework; check for existing URLs being loaded and build up an library of content - rather then creating/loading individual stage instances for each asset? If you think of content stored in a library, then you can get developers to "clear" the library of unused assets. The problem I have at the moment is that assets aren't quite ready quick enough because of the inherent delay going off to the server/cache to check for a downloaded file, rather then pulling items straight from memory.
  5. From your description, something like: //... setup ... // var _queue = new LoaderMax({name:"frameLoader", onComplete:QueueComplete, onProgress:QueueProgress, onError:QueueError}); _queue.append(new SWFLoader("nameOfSwf1.swf", {name:"menu1", onComplete:Menu1Complete, estimatedSize:20000}); _queue.append(new SWFLoader("nameOfSwf2.swf", {name:"menu2", onComplete:Menu2Complete, estimatedSize:20000}); _queue.append(new SWFLoader("nameOfSwf3.swf", {name:"menu3", onComplete:Menu3Complete, estimatedSize:20000}); _queue.append(new SWFLoader("nameOfSwf4.swf", {name:"menu4", onComplete:Menu4Complete, estimatedSize:20000}); //... button press ... // _queue.prioritize("menu1"); //... event handler functions ... // addChild(_queue.getLoader("menu1").content); Edit: Fixed example code, adding in "nameOfSwf.swf" properties
  6. Hey all, I wrote an extention to ImageLoader called ImageCache, which takes a snapshot of a loaded bitmap and stores it in a local cache. That way, when subsequent calls for the same bitmap data are made they can be delivered to the screen instantly without any delays. Also, I found that this optimization helps with prototyping where I need an external image on the stage "now", but want to write a preloader further down the line. This way the image can be preloaded either before hand, or loaded when required, with the benefit of no-delay drawing if preloaded, and without having to rewrite my display code after the preloader is written. I think I've covered the correct event hooks, but haven't used LoaderMax much - so if anyone could test/improve this code please let me know. /** * VERSION: 1.00 * DATE: 2011-05-26 * AS3 **/ package com.greensock.loading { import flash.display.BitmapData; import flash.display.Bitmap; import flash.events.Event; /** * Extended version of ImageLoader for bitmaps, jpegs, gif, pngs that creates a bitmap cache after each image load and instantly completes subsequent requests for the same URL. * * See ImageLoader class for full greensock documentation on using LoaderMax and the ImageLoader. * Example usage: * image = new ImageCacher('images/photo1.jpg', {smoothing:true}); image.load(); * * author: John Beech, johnbeech@mkv25.net */ public class ImageCacher extends ImageLoader { private static var _classActivated:Boolean = _activateClass("ImageCacher", ImageCacher, "jpg,jpeg,png,gif,bmp"); protected static var BITMAP_INDEX:Object = {}; public function ImageCacher(urlOrRequest:*, vars:Object=null) { super(urlOrRequest, vars); _type = "ImageCacher"; } /* Check cache for bitmap first before performing load, unless told to flushContent */ override public function load(flushContent:Boolean=false):void { var bitmap:BitmapData = GetBitmap(this.url); if(bitmap == null || !flushContent) { super.load(flushContent); } else { _content = new Bitmap(bitmap, "auto", Boolean(this.vars.smoothing != false)); super._completeHandler(); } } /* On completion take a snapshot of the content and store in cache */ override protected function _completeHandler(e:Event=null):void { _determineScriptAccess(); if (!_scriptAccessDenied) { var bitmap:BitmapData = new BitmapData(_content.width, _content.height, true, 0x0000FF); bitmap.draw(_content); ImageCacher.SetBitmap(this.url, bitmap); } else { throw new Error("Security sandbox exception, cannot cache image."); } super._completeHandler(e); } /* Store a loaded bitmap in an internal cache */ public static function SetBitmap(name:String, bitmap:BitmapData):void { BITMAP_INDEX[name] = bitmap; } /* Return a loaded bitmap from the internal cache */ public static function GetBitmap(name:String):BitmapData { return BITMAP_INDEX[name]; } } }
×
×
  • Create New...