views:

64

answers:

2

Hello Community.

I'm doing an Image Cache following this method: http://www.brandondement.com/blog/2009/08/18/creating-an-image-cache-with-actionscript-3/

I copied the two as classes, renaming them CachedImage and CachedImageMap.

The thing is that I don't want to store the image after being loaded a first time, but while the application is being loaded.

For that, I've created a function that is called by the application pre-initialize event. This is how it looks:

private function loadImages():void
        {
            var im:CachedImage = new CachedImage;

            var sources:ArrayCollection = new ArrayCollection;

            for each(var cs in divisionData.division.collections.collection.collectionSelection)
            {
                sources.addItem(cs.toString());
            }

            for each(var se in divisionData.division.collections.collection.searchEngine)
            {
                sources.addItem(se.toString());
            }

            for each( var source:String in sources)
            {
                im.source = source; 
                im.load(source); 
            }
        }

The sources are properly retrieved. However, even if I use the load method, I do not get the "complete" event... As if the image is not being loaded... How is that?

Any help would be appreciated.

Thanks in advance. Regards,

BS_C3

A: 

Hi!

I found the problem with my code =) It was a declaration problem.

I moved the declaration of the cachedImage inside the for each loop where the images are loaded. So that I get something like this:

for each( var source:String in sources)
{
    var im:CachedImage = new CachedImage;
    im.source = source; 
    im.load(source); 
}

And this does the trick.

Regards, BS_C3

BS_C3
A: 

Thanks For Image cache code flex development india

kevin