Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a sequence of Swf's on a web page, How do I do this?

Status
Not open for further replies.

jydeda

Technical User
May 31, 2006
8
GB
Being a new user at flash, web pages and Java I'm a bit stuck . . . . .I want to load a sequence of flash movies one after the other into my web page and then have the sequence go back to the beginning of the sequence and start again

How do I do this. Please note that I dont want the slide shows to be merged into one huge SWF file.

At the moment the it loads the first and second file but it wont go on to load the third the code as it stands is as follows

Here is the code as it stands:

var slideshowNum = 1;

function linkslideshow() {
window.alert("Current display is slideshow image " + slideshowNum + ".");
}
function rotateslideshow() {
if (++slideshowNum > 12)
slideshowNum = 1;

onLoad=window.setTimeout('rotateslideshow();', 1000);
document.write("<param name=\"BGColor\" value=\"ccff33\">");
document.write(' <PARAM NAME=movie VALUE="images/slideshow2.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=menu VALUE=false>');
document.write(' <EMBED src="images/slideshow2.swf" quality=high" ');
document.write(' "images/slideshow" + slideshowNum + ".swf"');
document.write(' " ');
document.write(' type="application/x-shockwave-flash"');
document.write(' pluginspage=" width=\"200\" height=\"300\"></embed></OBJECT>');
 
I thought this was very interesting concept so I finished up your HTML:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JS SWF sequential load</title>

<script language="JavaScript" type="text/javascript">
<!--
var slideshowNum = 1;
function init(){
	setTimeout("rotateslideshow()", 1000);
}
function rotateslideshow(){
	slideshowNum++;
	if(slideshowNum > 12){
		slideshowNum = 1;
	}
	var html = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\"[/URL] width=\"300\" height=\"200\">\n";
	html += "<param name=\"movie\" value=\"images/slideshow" + slideshowNum + ".swf\" />\n";
	html += "<param name=\"quality\" value=\"high\" />\n";
	html += "<embed src=\"images/slideshow" + slideshowNum + ".swf\" quality=\"high\" pluginspage=\"[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer\"[/URL] type=\"application/x-shockwave-flash\" width=\"300\" height=\"200\"></embed>\n";
	html += "</object>";
	document.getElementById("flash").innerHTML = html;
	setTimeout("rotateslideshow()", 1000);
}
//-->
</script>
</head>

<body onload="init()">
<div id="flash">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"[/URL] width="300" height="200">
  <param name="movie" value="images/slideshow1.swf" />
  <param name="quality" value="high" />
  <embed src="images/slideshow1.swf" quality="high" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] type="application/x-shockwave-flash" width="300" height="200"></embed>
</object>
</div>
</body>
</html>

I tested this on Firefox and IE on PC and works fine, but I can't be certain if it works on other browsers and platforms.

That is exactly one of the reason why you SHOULD NOT do this - you don't know if it works unless you test on everything, which is impossible. Other reasons are:
[ul]
[li]With this method Flash object needs to be re-created on every timeouts, so the page flashes every time (no pun) and also it's strenuous to the browser[/li]
[li]If JS is disabled it won't work[/li]
[/ul]

There is far better way of doing this - create a "base/container" SWF and load your SWF slides into it in sequence. You can offer much superior experience to your audience with this "container SWF" approach.

Kenneth Kawamoto
 
Cheers Kenneth

thanks a lot I'll go and try this out right away. I adapted the idea from the way images are swaped on a web page, and Like you say I'm sure there is a more efficient way.

The purpose is to create a primitive metronome without using lengthy programming. I created a method of teaching myself Bass guitar scales and arpeggios using changing images of the fret board, displaying a sequence of finger board images with marked positions that I can follow on my instrument. It works really well even a novice can pick up the principles in a week and play very well.

I find it works better if there is a metronome count behind the rotating sequence of images. To create this metronome effect I'm using a series of simplified Flash movies (one keyframe each) as a simple way of creating the metronome sound combined with an image of a number to create the metronome count. Playing a sequence of these short flash movies appended into an HTML page gives the illusion of a metronome. You could say why not just use an external metronome. Well the whole idea is to get the metronome to syncronize in time with the display of other images within the HTML frameset when loaded. By syncing I mean it will play in time with the rotation of the images of the scales.

so the sequence would need to be very adjustable in terms of speed and duration.

I would like to up load this teaching method some day so what you say is true that, the method may not be highly efficient for the reasons you mentioned.

I would like to know more about creating a "base/container" SWF. Can you suggest any websites or reading material. In the mean time the site is still being developed offline so it does not realy matter for now.

Best regards
 
I am not sure if the timing is accurate enough to be used as metronome if you use this Javascript timeout method. Plus there'll be a time delay as the browser has to create Flash object and load the SWF every time.

I don't think Flash is that time accurate either but I think its time keeping is better than browsers. Still, loading external SWFs can cause time lags. You can load all the SWFs at the beginning and just show them on stage in sequence to avoid that. Or make one big SWF (I know you said you didn't want that!)

Just read MovieClip.loadMovie() method in the manual if you're interested.

Kenneth Kawamoto
 
I think the time lag issue is negligible becuase the file sizes are so very tiny. They are literally one cow bell sound layered with one keyframe of a low rez image of a number. Anyway like I said its worth tryng out first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top