Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Dcoo

best way to update an image loader for my image gallery?

Recommended Posts

my gallery is loaded from an xml doc that is dynamically generated , when a user takes webcam picture the xml doc gets updated, I would like to add this new pic to the gallery. what would be the best way to do this? 

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

Not exactly sure what type of help you need. Once the xml gets updated and re-loaded, you would just need to

 

  1. grab the new url
  2. pass the url to a new ImageLoader
  3. load() the ImageLoader
  4. add the new image to your gallery

Or perhaps you may have a LoaderMax that handles loading and displaying all the images, in that case you would just append() the new ImageLoader to your LoaderMax and then have the LoaderMax instance load the images.

Link to comment
Share on other sites

"Once the xml gets updated and re-loaded" Its the re-laoding of the xml that am not sure how to do.

Link to comment
Share on other sites

If you are using an XMLLoader to load it the first time, you can reload it like so

 

myXMLLoader.load(true) 

 

setting the flushContent parameter to true will remove the previously loaded xml and reload the file again.

Link to comment
Share on other sites

Thank you Carl, Is there possible an example of that code being implemented out there some where ?

Link to comment
Share on other sites

No, not that I know of. This tutorial http://www.snorkl.tv/2011/08/loading-images-with-loadermax-part-2-the-xmlloader/ shows the basics of loading an xml doc and all the images listed in it, but it wasn't crafted to be loaded multiple times with new data.

 

It seems you already are loading xml and images, not really seeing what the problem is with loading xml and image data again. 

Link to comment
Share on other sites

Yes I can get it to load the first time. so not one examples shows how use the reload button, as that is the function I can't seem to get to work.

Link to comment
Share on other sites

  • 7 months later...

I cant seem to get flushContent to work :(  I have something missing from my code but not sure what. in my example below I'm not using xml, just loading one jpg 

 

If you are using an XMLLoader to load it the first time, you can reload it like so

 

myXMLLoader.load(true) 

 

setting the flushContent parameter to true will remove the previously loaded xml and reload the file again.

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;


import flash.filesystem.*;
LoaderMax.activate ([ImageLoader]);


var file:String = "IMG_happy.jpg";
var mypic:File = File.applicationStorageDirectory.resolvePath("Photos/"+file);

var myImage:ImageLoader = new ImageLoader(mypic.url,{container:this,x:0,y:0,width:414,height:309});


myImage.load(true);

by the way, this code works in air on iOS to load a saved image from applicationStorageDirectory, if anyones interested :)

Link to comment
Share on other sites

when a new picture is taken, it overwites IMG_happy.jpg in the photos folder, but doesn't update until the app is restarted

import com.greensock.*;import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;


import flash.filesystem.*;
LoaderMax.activate([ImageLoader]);


var file:String = "IMG_happy.jpg";
var mypic:File = File.applicationStorageDirectory.resolvePath("Photos/"+file);

var myImage:ImageLoader = new ImageLoader(mypic.url,{container:this,x:0,y:0,width:414,height:309,onComplete:onImageLoad});

myImage.load(true);

function onImageLoad(event:LoaderEvent):void {
  TweenLite.from(event.target.content, 1, {alpha:0});
 }
Link to comment
Share on other sites

The code you are showing appears to load an image once. I don't see where you are running code that calls myImage.load(true) again. Or perhaps where your app is being notified that the image has changed.  Unfortunately I don't do any AIR for iOS development and ImageLoader was intended for http streaming so I'm not really sure how air is caching your image or what the problem might be. Sorry.

Link to comment
Share on other sites

I don't think its has any thing to do with IOS, I cant get it to work in a browser :)

But you say you don't see me call it again? Is it really the easy? I just call it again? 

 

Oh dang it is!

it works!!

I called it from my camera on save,
 

Object(root).faceW.myImage.load(true); 
 

So cool!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×