Topic: Pausing

ok, so I added

setInterval(Delegate.create(this,onClickNext), 3000);

to get the thumbnails to scroll, is there a way to pause/play the scrolling?

-Steve

Re: Pausing

To start slideshow:

var show_int =  setInterval(Delegate.create(this,onClickNext), 3000);

To stop:

clearInterval(show_int);

Felix Turner
SimpleViewer Support Team.

Re: Pausing

I'm sorry, i'm very new at flash, could you point me in the direction on how to implement that code?

Re: Pausing

Here is some very basic logic that implements a slideshow in SV Pro 1.8. I've kept my example simple -- no new buttons or controls are used -- by modifying a fairly standard install of SV. Hopefully it's easy enough to get you started and not so simple to be of no use.

You'll start by modifying the ImageArea.as file. We want the init() function. Right after this line of code (~ line 107)

col.setRGB(mXMLManager.imageFrameColor);

and before the function's closing brace ( } ) you want to insert this line of code

mIntervalId = setInterval( Delegate.create( this, onClickNext ), mSlideShowDuration );

This guy does the work. It's a timer that calls onClickNext, but it depends on variables we've not yet set. So let's set 'em...

The beginning of the ImageArea class is where all our variables are defined. (Well, it's where you ought to define them if you enjoy tidy code.) Look for a suitable blank spot, say line 47 or so, and insert 2 lines

private var mSlideShowDuration:Number = 3000;
public var mIntervalId:Number;

Now we have a public reference to our timer, mIntervalId, and we have a private reference to the duration between calls, mSlideShowDuration. (The duration is in milliseconds.) You'll notice all the other variables here are private. We're making mIntervalId public in order to be able to call it from  outside of the ImageArea class.

The slideshow would work now. It would start as soon as your first image displayed and continue until the final image was shown. But we need a way to disable it. I've chosen to disable the show as soon as any thumbnail is clicked.

To do this, we need to edit the Thumb.as file and look for private function onRelease(). (You might find the function declared around line 212.) On the last line of the function (before the closing brace) insert this code

clearInterval( mImageArea.mIntervalId );

to stop the slideshow. Now when a thumbnail is selected (a click, a dragout, etc) the reference to our timer is cleared and the slideshow stops.

Re: Pausing

and a non stop slideshow? I mean, when the last image appears, go back to number 1.

Re: Pausing

To achieve a continuously looping slideshow effect using the changes above, you'll need to edit the ImageArea.as file.

Find the private function onClickNext() at about line 235, which is

private function onClickNext():Void{        
    mThumbArea.selectedThumbIndex ++;    
}

and change it to

private function onClickNext():Void{        
    if ( mThumbArea.selectedThumbIndex != ( mXMLManager.imageCount - 1 )) {
        mThumbArea.selectedThumbIndex ++;    
    } else {
        mThumbArea.selectedThumbIndex = 0;
    }
}

The effect of these changes is--
1) A slideshow that auto-starts,
2) A slideshow that stops whenever a thumbnail image is selected, and
3) A viewer that still responds to image navigation while the slideshow is running.

Re: Pausing

how would you get it so they can restart the slideshow after they click on an image to stop it?

Re: Pausing

This is working, but I would like to wait with the start, until the last image is loaded, or atleast some of them!
In my gallery there are some bigger files (above 200K each) and with a slower connection it looks pretty awfull:
You see the LOADING IMAGE text and the bar starts loading and after 3 seconds (as set above) it fades out, then a new LOADING IMAGE text and empty bar fades in for 3 seconds...

I just tried to find a way to have one, big IMAGES ARE LOADING text with a HUGE smile bar, but I am just to new to flash.

Any idea?

(I have no thumbnails, or image arrows in this gallery, because this is on the front page. As you go to a subpage, there you will have thumbs and arrows)

Thanks.

Re: Pausing

It seems that I have found a solution! smile
The slideshow moves to the next image only if it is loaded. This way I dont have to care about all the images, only the next one.

I don't if this code good, efficient, or such, but it works so i like it. smile

private function onClickNext():Void{      
if (mImages[mCurrentImageIndex+1].loaded && !mImages[mCurrentImageIndex+1].imageLoadError) {

        if    ( mThumbArea.selectedThumbIndex != ( mXMLManager.imageCount - 1 ))  {
              mThumbArea.selectedThumbIndex ++;   
           } else {
              mThumbArea.selectedThumbIndex = 0;
           }
    }
}

Any suggestions?

Re: Pausing

Sorry. The code above just didnt loop. But thisone does:

private function onClickNext():Void{      

        if    ( mThumbArea.selectedThumbIndex != ( mXMLManager.imageCount - 1 ))  {
                  if (mImages[mCurrentImageIndex+1].loaded && !mImages[mCurrentImageIndex+1].imageLoadError) {
                    mThumbArea.selectedThumbIndex ++;   
                }
           } else {
              mThumbArea.selectedThumbIndex = 0;
           }
    }

w.

Re: Pausing

Hi, i just bought the pro version of simpleviewer but need some help.
I tried these modifications to make a looping slideshow and everything works, i just have 2 questions:

- how can i modify the transition speed of the big images
- how can i have the slideshow stop even on the click of the thumbnail next and prev arrows (now with the slideshow active it's almost impossible to scroll through the thumbnails because it will go back to the active thumb)

Re: Pausing

as with bostonaperture, anyone understands how to restart the slideshow once the interval is cleared from the thumb.as?

Re: Pausing

anyone understands how to restart the slideshow once the interval is cleared from the thumb.as?

recall the first piece of code:

setInterval(Delegate.create(this,onClickNext), 3000);
Felix Turner
SimpleViewer Support Team.

Re: Pausing

hi felix,
yeah i was trying to use that line. i'm not familiar with OOP and using different .as files. I was trying to create a seperate button on stage to start and pause (i know this is not what u meant SimpleViewer for), so I wasn't sure how to initiate that kind of script. Thought I couldn't just place the script on an on(release) event or something.

Re: Pausing

hello,

i try to add a button which start/stop the slideshow, did someone have an idea to do this?

Re: Pausing

Thanks for this code, it is very usefull.
Can you make this slideshow stop when someone click on the navigation arrows on the image themselves (I'm not using the thumbnails)?
I tried to put

clearInterval( mImageArea.mIntervalId );

into the Onrelease function in RolloverButton.as  but I've a code error.

Re: Pausing

That won't work because mIntervalId is a private variable. To fix this, define mIntervalId as public in ImageArea.as.

Felix Turner
SimpleViewer Support Team.

Re: Pausing

Here's a way to start/stop the slideshow from the context (right-click) menu.

I should say that I'm not a programmer and I hardly know flash or actionscript, so this is perhaps not the neatest method of doing this:

In imagearea.as create two new menu items round about line 48:

[code[private var menuStartAuto:ContextMenuItem;
private var menuStopAuto:ContextMenuItem;[/code]

Add these two lines in the init function (circa line 104 - not sure of the exact numbers in the original code since mine's been hacked around)

menuStartAuto = new ContextMenuItem("Start Slideshow", Delegate.create(this,startAuto));
menuStopAuto = new ContextMenuItem("Stop Slideshow", Delegate.create(this,stopAuto));

That sets up the two menu items to run functions to start and stop the slide-show. Also add these lines:

image_cm.customItems.push(menuStartAuto);
image_cm.customItems.push(menuStopAuto);
menuStopAuto.visible = false;

That adds the menu items to the menu but makes the "Stop" one invisible.

Then at the end of the file include this:

private function startAuto() {
  clearInterval ( mIntervalId ); //avoid orphan timers
  mIntervalId = setInterval( Delegate.create( this, onClickNext ),   mSlideShowDuration );
  menuStopAuto.visible = true;
  menuStartAuto.visible = false;
}
private function stopAuto() {
  clearInterval( mIntervalId );
  menuStopAuto.visible = false;
  menuStartAuto.visible = true;
}

Re: Pausing

I too am trying to stop the slideshow when the image or thumbnail arrows are clicked. I added

clearInterval( mImageArea.mIntervalId );

to the onRelease function in RolloverButton.as and added

import com.airtightinteractive.apps.viewers.simpleViewer.ImageArea;

to the top of the page. mIntervalId is a public variable and I do not get an error message but the slideshow does not stop.

I also tried alec's method but that didn't make any difference either.

Any ideas?

Re: Pausing

Slideshow/AutoPlay mode has been added in SimpleViewer-Pro v1.9. Pro users can use their original download link to get the latest files.

Felix Turner
SimpleViewer Support Team.

Re: Pausing

With the 1.9 update, how do you get it to loop continuously?

Thanks for any information!

-Lucas

Re: Pausing

Set the 'enableLooping' AS option to true: http://www.airtightinteractive.com/simp … tions.html

Felix Turner
SimpleViewer Support Team.