PDA

View Full Version : How to change swf files by clicking a button


aammaguiar
12-10-2008, 01:38 AM
Can anyone show me how to do this:
1. Display page1.swf (it is a page from a magazine in a swf file, not a movie)
2. Show a button that says "Change page"
3. When I click the button display page2.swf
4. Same thing on each click, to display page 3.swf, page4.swf, ...

I have tried writing javascript to do this, but I just can't get it to work. I am a real novice at this so any help would be greatly appreciated.

codemaster
12-18-2008, 07:42 PM
<html>
<head>
<title>Page Title Here</title>
<script language="javascript" type="text/javascript">
<!--
function switchswf (dir) {
var pageswf = document.getElementById('pageswf').src;
if (dir>0) {
document.getElementById('pageswf').src='page'+(par seInt(pageswf.substring(4,pageswf.length-4))+1)+'.swf';
} else if (dir<0) {
if (parseInt(pageswf.substring(4,pageswf.length-4))>1)
document.getElementById('pageswf').src='page'+(par seInt(pageswf.substring(4,pageswf.length-4))-1)+'.swf';
}
}
//-->
</script>
</head>
<body>
<embed id="pageswf" src="page1.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="100">
</embed>
<br />
<button onclick="switchswf(-1);">Previous</button>
<button onclick="switchswf(1);">Next</button>
</body>
</html>

codemaster
12-18-2008, 07:48 PM
That should work