1 (edited by jositako 2012-05-11 17:29:47)

Topic: SOLVED: Which variable to use to know which image is showing...

I would like to be able to attach an image to an e-mail from my gallery that is showing (in an iPhone app). So when let's say image_1 is showing, pressing a button would attach this image to the e-mail, when image_2 is showing, that image would be attached, etc. The button works to attach an image, but not the image that is showing... :(

The question is how do I know (image name) which image is showing? I would like to use that variable in the script attaching the current image showing to the e-mail.

Thank you!

Re: SOLVED: Which variable to use to know which image is showing...

You can use the SimpleViewer-Pro API and the getImageInfo() method to obtain the imageURL of the currently displayed image.
Take a look at the online demonstration of the JavaScript API and view the source of the page for details of how to use the API Methods and Events.
A cut down version of the demo page with a single button which will display the current imageURL follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <title>SimpleViewer JavaScript API Example</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="svcore/js/simpleviewer.js"></script>
    <script type="text/javascript">

        var svAPI;

        function svComplete() {
            svAPI = document.getElementById('svInstance');        
        function getCurrentImageURL() {
            var imageInfo = svAPI.getImageInfo(svAPI.getImageIndex());

        var flashvars = {};
        flashvars.enableAPI = "true";

        var params = {};
        params.allowscriptaccess = "always";

        var attributes = {};
        attributes.id = "svInstance";
        attributes.name = "svInstance";

        simpleviewer.ready(function() {
            svAPI = simpleviewer.load('sv-container', '800', '600', '222222', true, flashvars, params, attributes);
    <div id="form"> 
        <form action="none">
                <input name="b1" type="button" value="Get Current imageURL" onclick="getCurrentImageURL()" />
    <div id="sv-container"></div>
Steven Speirs
SimpleViewer Support Team

Re: SOLVED: Which variable to use to know which image is showing...

Works like a charm, I just used getImageIndex() instead.  :)

Thank you!