Topic: V1.4 direct link to image (kind of!) [SOLVED]

Hi.

Old I know, but I still use the older V1.4.

I wanted to add an option to goto an image directly from the query string in the browser, but cannot do this in version 1.4 by the looks of it, but can from 1.9

I upgraded to 1.9, and had to alter the XML to allow for this (not a huge deal, as my XML forums are created on the fly just before the album is opened in flash, if no XML file exists (so I can simply delete the old ones, and they re-create automatically with the newer tags).

My old 1.4 had no thumbnails, and would scroll three images wide, which is what I like, I want to keep, but I cannot seem to get this going with the 1.9 version?

I have reverted back to the older one: http://www.askthetrades.co.uk/cgi-bin/y … ideshowtop

Is it possible to have this three image layout in a newer version?

thanks!

Re: V1.4 direct link to image (kind of!) [SOLVED]

The gallery you provided a link to is an AutoViewer gallery.
This is a completely different image viewer to SimpleViewer.

It is not possible (and has never been possible) to display partial previous and next images to the left and right of the main image in SimpleViewer. This is a feature of AutoViewer only.

Steven Speirs
SimpleViewer Support Team.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Ah, OK, My bad.

Could this post be moved to that forum instead then?

Is direct image access available in Albumviewer?  Starting the Albumviewer at image 4 for example?

Thanks.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Is direct image access available in Albumviewer?  Starting the Albumviewer at image 4 for example?

No. AutoViewer-Pro does not natively support direct linking to individual images within a gallery but AutoViewer-Pro does come with source code so with Adobe Flash Professional and knowledge of ActionScript, you may be able to modify the application in order to support this functionality.
For more information about customizing source code, please see here.

The only two of our image viewers which support direct linking to individual images within a gallery are SimpleViewer and Juicebox.

[Thread moved to AutoViewer forum.]

Steven Speirs
SimpleViewer Support Team.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Thanks.

It's not a huge deal to be honest, certainly not worth me investing in Adobe.

If someone was able to make the tweak, I would be interested in making a donation to them.

Re: V1.4 direct link to image (kind of!) [SOLVED]

If you download a trial version of Adobe Flash Professional, the following works. (I have tested it.)

(1) Modify the 'autoviewer_pro\source\com\airtightinteractive\apps\viewers\autoViewer\StageManager.as' file as follows.
(1.1) On line 52 (currently blank), add the following:

private var imageIndex:Number = 0;

(1.2) On line 85 (currently blank), add the following:

if (_root.imageIndex != undefined) {
    imageIndex = _root.imageIndex;
}

(1.3) Change line 163 from:

showImage();

... to:

showImage(imageIndex);

(2) Publish a new SWF file ('File -> Publish').

You would extract the imageIndex from the query string and set it as a flash variable in your gallery's embedding code using JavaScript as follows:

<div id="flashcontent">AutoViewer requires JavaScript and the Flash Player. <a href="http://www.macromedia.com/go/getflashplayer/">Get Flash here.</a> </div>    
<script type="text/javascript">

    var firstImageIndex = 0;
    if (location.search) {
        var queryString=unescape(location.search), queryArray={}, re=new RegExp("([^?=&]+)(?:=([^&]*))?", "g"), queryComponent=null, queryInteger=0;
        while (queryComponent=re.exec(queryString)) {
            queryArray[queryComponent[1]]=queryComponent[2];
        }
        queryInteger=parseInt(queryArray["imageIndex"]);
        if (!isNaN(queryInteger) && queryInteger>0) {
            firstImageIndex=queryInteger-1;
        }
    }

    var fo = new SWFObject("autoviewer.swf", "autoviewer", "100%", "100%", "8", "#181818");        

    fo.addVariable("imageIndex", firstImageIndex);

    fo.write("flashcontent");    

</script>

   
You can now go directly to a specific image in an AutoViewer-Pro gallery using the variable imageIndex in a query string in the URL, e.g.:
http://www.example.com/gallery/index.html?imageIndex=4 (to display the 4th image in the gallery)

Steven Speirs
SimpleViewer Support Team.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Perfect.

Not got time this morning, but will have a go later with this.

Thanks for that, very concise.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Umm.

I have upgraded to the pro version and downloaded the source code.

I have Adobe Flash Professional CC running as a 30 day demo.

It comes with ActionScript 3.

When I compile the movie, even without editing any files at all, the compilation fails on the below error:

\autoviewer_pro\source\com\airtightinteractive\apps\viewers\autoViewer\StageManager.as, Line 1, Column 1    5007: An ActionScript file must have at least one externally visible definition.

Is this possibly because the original was written in ActionScript 2, and it is being compiled in ActionScript 3?  There is no way to use ActionScript 2 in the demo I have - I it says all ActionScript 2 code must be changed to reflect ActionScript 3?

Thanks.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Ah, Ok.  I have got somewhere!  I was meant to use "Macromedia Flash 8"?

I have used that instead to publish without errors.

The only tweak I needed to make to the code you gave above (thanks!), is below, as images start at 0, not 1.

if (_root.imageIndex != undefined) {
  imageIndex = _root.imageIndex;
  if(imageIndex > 0){ imageIndex--; }
}

   

instead of:

if (_root.imageIndex != undefined) {
    imageIndex = _root.imageIndex;
}

This then works perfectly, with my querystring being start=1, being image 1, start=6, being image 6 etc.  My initial HTML album is created in Perl, and I use the Perl code to dynamically place the image number in the fo.addVariable("imageIndex", #n);  I also get the Perl script to count the image quantities in the album, and if you use the querystring start=last, it adds the last images number to the fo-adVariable.

All works great, and means the links I have in my HTML album under each image "Start Slide Show" now start the slide show at the position of the image, not the start.

Thanks for the help - It certainly got me doing something I would not of usually tackled!

Re: V1.4 direct link to image (kind of!) [SOLVED]

I'm glad you have been able to formulate a solution that works for you.

as images start at 0, not 1

The internal code for AutoViewer uses 0 for the first image so I kept this convention in my own solution.
The ActionScript code just uses the imageIndex flash variable directly and the JavaScript code substracts 1 from the imageIndex query string value to compensate for the image index starting at 0.

Steven Speirs
SimpleViewer Support Team.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Steven Speirs wrote:

I'm glad you have been able to formulate a solution that works for you.

as images start at 0, not 1

The internal code for AutoViewer uses 0 for the first image so I kept this convention in my own solution.
The ActionScript code just uses the imageIndex flash variable directly and the JavaScript code substracts 1 from the imageIndex query string value to compensate for the image index starting at 0.

I could of done the subtraction in Perl, or in Autoviewer, perhaps it would of been better in Perl.

Thanks again.

Re: V1.4 direct link to image (kind of!) [SOLVED]

As I have the facility to tweak at the minute (30 day trial!, lol), I thought I would tweak a little more.

The XML attribute "displayTime" sets the auto play speed.

I thought I would add a querystring to allow users to alter this themself via a drop down options box, and tweaked as below:

Original:

  var dt = Number(xmlRoot.attributes.displayTime)*1000;    
  if (isValidNumber(dt)) displayTime = dt;

New:

  var dt = Number(xmlRoot.attributes.displayTime)*1000;
  if (_root.displayTime != undefined){ dt = _root.displayTime*1000; }    ##<<New line.    
  if (isValidNumber(dt)) displayTime = dt;            

                   
This works fine.

What I would like to do is when someone changes the the options drop down, the page will reload, so would like the page to reload onto the image that was last viewed.  To do this, I would like to pass the image index number back to javascript each time an image is displayed - I thought this would be easy using getURL("javascript:returnImageNo('test return - '+index);");, but although values are passed back, they are random.  I have tried placing this code in various places, but cannot work out where it would go to do as I want?

Do you think this is possible at all?

Thanks alot.  Appreciate your help.

Last edited by Lectrician (2014-02-09 09:30:57)

Re: V1.4 direct link to image (kind of!) [SOLVED]

I would like to pass the image index number back to javascript each time an image is displayed

Add the following to the imports at the top of the 'StageManager.as' file:

import flash.external.*; 

At the end of the showImage() function, add the following code:

ExternalInterface.call('updateIndex', index);

In the HTML page containing the gallery's embedding code, add the following code:

<script>
    var currentImageIndex;
    function updateIndex(index) {
        currentImageIndex = index;
    }
</script>

Each time a new image is displayed, the showImage() ActionScript function is run.
At the end of the showImage() ActionScript function, the JavaScript function updateIndex() is fired, passing the current image index as the parameter.
The JavaScript function itself then updates a variable (currentImageIndex) with the current image index and you can refer to this variable whenever you like within your own code.
(Again, you may need to compensate for the image index starting at 0.)

Steven Speirs
SimpleViewer Support Team.

Re: V1.4 direct link to image (kind of!) [SOLVED]

Works perfectly, thanks!