I have created one of my own, but it is surely not the best way to do it?
Nevertheless, I will share it with you:
Image.as:
<code>
/**
* @class : Image
*
* @author : Cor van Dooren
* @version : 1.0
*
* @usage : Load a PNG, JPG, GIF or SWF file
* @syntax : var myIMG:Image = new Image(param);
* @param : String: bv. "img/your_file.png"
*/
package ecemel.codo {
//--------------------------- I M P O R T S
---------------------------------------------------------------
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.*;
import flash.errors.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.text.*;
import flash.utils.*;
import flash.media.*;
import flash.system.*;
import flash.ui.*;
import flash.xml.*;
import fl.containers.*;
import fl.controls.*;
import fl.controls.listClasses.*;
import fl.data.*;
import fl.video.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import fl.managers.*;
//--------------------------- C L A S S
-----------------------------------------------------------
public class Image extends MovieClip {
//--------------------------- P R I V A T E V A R I A B L
E S -----------------------------------------
public static var imgBreedte:Number;
public static var imgHoogte:Number;
//--------------------------- P R I V A T E V A R I A B L
E S -----------------------------------------
private var ldr:Loader;
private var url:String;
//--------------------------- C O N S T R U C T O R
-----------------------------------------------------
public function Image(psdURL:String=null) {
url = psdURL;
addEventListener(Event.ADDED_TO_STAGE, init, false,
0, true);
}//end CONSTRUCTOR
//--------------------------------------------------------------------------
-----------------------------
//# # # # P R I V AT E F U N C T I O N S
# # # # #
//--------------------------------------------------------------------------
-----------------------------
//--------------------------- i n i t
-------------------------------------------------------------------
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
loadImage();
}//end init
//--------------------------- l o a d I m a g e
---------------------------------------------------------
private function loadImage():void {
ldr = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler,
false, 0, true);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,
ioErrorHandler, false, 0, true);
ldr.load(new URLRequest(url));
}//end loadImage
//--------------------------- c o m p l e t e H a n d l e r
---------------------------------------------
private function completeHandler(e:Event):void {
if (url.slice(url.length - 3,url.length) != "swf") {
//trace("Het is een",url.slice(url.length -
3, url.length));
var bitmapImage:Bitmap = e.target.content;
bitmapImage.smoothing = true;
}
e.target.removeEventListener(Event.COMPLETE,
completeHandler);
e.target.removeEventListener(IOErrorEvent.IO_ERROR,
ioErrorHandler);
imgBreedte = ldr.contentLoaderInfo.width;
imgHoogte = ldr.contentLoaderInfo.height;
//trace("Image.imgBreedte",Image.imgBreedte,"Image.imgHoogte",Image.imgHoogt
e)
addChild(ldr);
}//end completeHandler
//--------------------------- i o E r r o r H a n d l e r
-----------------------------------------------
private function ioErrorHandler(e:IOErrorEvent):void {
addChild(new Pagina404("Image "+url+" niet
gevonden."));
}//end ioErrorHandler
}//end CLASS
}//end PACKAGE
</code>
Regards
Cor
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Karl
DeSaulniers
Sent: zaterdag 18 september 2010 13:02
To: Flash Coders List
Subject: Re: [Flashcoders] Best (fastest/memory efficient) way to animate
bitmaps
That one is actually by jeroenwijering.
But the one I have is from martijndevisser
sry.
Best,
Karl
On Sep 18, 2010, at 5:14 AM, Cor wrote:
> And where can I download THIS ImageLoader.as
>
> Regards
> Cor
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Karl
> DeSaulniers
> Sent: maandag 13 september 2010 2:48
> To: Flash Coders List
> Subject: Re: [Flashcoders] Best (fastest/memory efficient) way to
> animate
> bitmaps
>
> Martijndevisser - ImageLoader.as
>
> With this you can load the images as they scroll. if you will. :)
> Very smooth and memory efficient that I have seen.
>
> Best,
> Karl
>
> On Sep 12, 2010, at 4:04 PM, Karim Beyrouti wrote:
>
>> found this method quite interesting: http://insideria.com/2010/08/
>> advanced-blitting-bitmap-scrol.html
>> not too sure it applies to mobile, but might help...
>>
>> On 12 Sep 2010, at 20:58, gamera wrote:
>>
>>> make a benchmark and find out.
>>>
>>> On Sep 8, 2010, at 8:50 PM, Kevin Newman wrote:
>>>
>>>> What is the fastest way to animate a series of bitmaps (say 20
>>>> frames).
>>>>
>>>> Here's a couple of ideas:
>>>>
>>>> A single big image behind a frame sized mask, move it one frame
>>>> onEnterFrame.
>>>>
>>>> A series of memory cached Bitmap objs, swap them using addChild/
>>>> removeChild (or set visible?) onEnterFrame.
>>>>
>>>> A series of memory cached BitmapData objs swap them by resetting
>>>> bmp.bitmapData onEnterFrame.
>>>>
>>>> Anything faster is nice too - particularly on mobile.
>>>>
>>>> Thanks!
>>>>
>>>> Kevin N.
>>>>
>>>>
>>>> _______________________________________________
>>>> Flashcoders mailing list
>>>> [email protected]
>>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>
>>>
>>> _______________________________________________
>>> Flashcoders mailing list
>>> [email protected]
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> Geen virus gevonden in het binnenkomende-bericht.
> Gecontroleerd door AVG - www.avg.com
> Versie: 9.0.851 / Virusdatabase: 271.1.1/3125 - datum van uitgifte:
> 09/09/10
> 20:34:00
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Karl DeSaulniers
Design Drumm
http://designdrumm.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 9.0.851 / Virusdatabase: 271.1.1/3125 - datum van uitgifte: 09/17/10
20:34:00
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 9.0.851 / Virusdatabase: 271.1.1/3125 - datum van uitgifte: 09/17/10
20:34:00
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders