• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Hour 17. Browser Navigation and Communic... > Task: JavaScript-Controlled Slidesho...

Task: JavaScript-Controlled Slideshow

Here's a task that can be performed easily with JavaScript, provided that the user has the right browser. In this task, we'll build a movie that doesn't have much of any ActionScript in it at all. The JavaScript on the HTML page, however, controls it completely.

Create a new Flash movie with three or more different frames in it. It doesn't matter what is on each frame, as long as you can easily tell the difference between frames.

Place a stop() command on the first frame so that the movie doesn't animate.

Publish the movie with a standard HTML page. There is no need to use the Flash with FSCommand template.

Using a text editor, open the HTML page.

Add an ID parameter to the OBJECT tag and a NAME parameter to the EMBED tag. Use “slideshow” as the value for both.

Also add an swLiveConnect=true to the EMBED tag.

Add two buttons to the HTML page. Use this code:

<FORM NAME="flashControlForm">
<INPUT NAME="next" TYPE=Button VALUE="Next" onClick="nextFrame();">
<INPUT NAME="prev" TYPE=Button VALUE="Previous" onClick="prevFrame();">

These two buttons call one of two functions. They both use TcurrentFrame("/") to get the number of the current frame and then GotoFrame to go to either the next or previous frame in the movie.

function nextFrame() {
  var frameNum = window.document.slideshow.TCurrentFrame("/");
function prevFrame() {
  var frameNum = window.document.slideshow.TCurrentFrame("/");



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint