Topic: as3 event listener

Hey how would you set up an event listener for

showNextImage()

showPreviousImage()

so when the nav buttons are clicked I can call a function

Thanks

Giles

Last edited by gilesadamthomas (2011-08-09 16:55:15)

Re: as3 event listener

You can use the svImageChange API Event which is fired when a new image is displayed.
Take a look at the 'onGalleryLoaded' function in the 'simpleviewer_pro_213/examples/flash_embed/simpleviewer_flash_embed.fla' file (from the SimpleViewer Pro download package) which includes the line:

svAPI.addEventListener("svImageChange",onImageChange);

... where 'onImageChange' is the name of the function called when svImageChange is fired.

Steven Speirs
SimpleViewer Support Team.

Re: as3 event listener

I tried this succesfully but it is also called when autoplay changes images and therefore can't be used in my situation - is there anything fired from just the nav arrow next/prev

Re: as3 event listener

is there anything fired from just the nav arrow next/prev

No. The only API Events that can be listened for can be found here: http://simpleviewer.net/simpleviewer/pr … tml#events

Steven Speirs
SimpleViewer Support Team.

Re: as3 event listener

thought so wanted to double check cheers

Re: as3 event listener

hi again
could I listen for a specific image or a number of specific images to be loaded eg showImage( index: int ) then use that to trigger a function

Re: as3 event listener

You could listen for the svImageChange event (using the line of code posted above in the onGalleryLoaded function) and your onImageChange function (fired every time an image is changed, either by the user or autoplay) might look something like this:

function onImageChange(e.Object){
    if (e.data == 2) {
        // do something, eg. call a function or insert code here, if the 3rd image (with index=2) is displayed
    }
    if (e.data == 8) {
        // do something different if the 9th image (with index=8) is displayed
    }
}
Steven Speirs
SimpleViewer Support Team.

Re: as3 event listener

thanks thats really helpful and fast!