1 (edited by Anton2 2010-06-13 21:58:00)

Topic: api onclick event

is it possible to add onClick event for thumb in API?

right now default events are:
1. click on thumb
2. default automatic responce to it - image change
3. firing up svImageChange() event

is it possible to split default automatic behavior in these steps:
1. click on thumb
2. firing up "svThumbClick" event, or some other suitable name, which will return clicked thumb(image) ID
3. default automatic responce - image change. BUT with possibility to stop it with some param.automaticImageChange=false (which will be "true" by default)
4. firing up svImageChange() event

what I'm trying to implement is SWFAddress using javascript, without need to edit .fla sources.
whole process might look like:
1. thumb click fires up svThumbClick() and gets clicked thumb's ID (let's call it thumbID)
1a. param.automaticImageChange=false, so automatic image change does not take place
2. SWFAddress.setValue('/pics/'+thumbID+'/')
3. SWFAddress.onChange() {
  - parsing url #/pics/picID/
  - svAPI.showImage(picID);
  - some other code perhaps

Feels good to have more freedom over possible actions )

Re: api onclick event


I updated the direct link example to change the link on image navigation: http://simpleviewer.net/simpleviewer/pr … ct_link/#5

please test it out and let me know if it does what you want.

Felix Turner
SimpleViewer Support Team.

3 (edited by Anton2 2010-06-15 10:38:17)

Re: api onclick event

Yeah, that's what I need!

but anyway had to add event listener for url change (back button).

settled with something similar to this:

      function getLocationIndex() {
        var paramArr = unescape(self.document.location.hash.substring(1)).split('/');
        return paramArr[1];

      function svImageChange(index){
        curLocationIndex = getLocationIndex();
        if(!curLocationIndex) { // user entered through '/'
          document.location = '#/'+index+'/';
        } else if(curLocationIndex != index) { // image has been changed through simpleviewer
            document.location = '#/'+index+'/';
      // the 'back button' listener
      SWFAddress.onChange = function(){
        if(svAPI.getImageIndex() != getLocationIndex()) {


Re: api onclick event


thanks for sharing Anton.

I've updated the example to include 'Back' button support: http://simpleviewer.net/simpleviewer/pr … dex.html#6

Felix Turner
SimpleViewer Support Team.