cookie_
01-04-2012, 07:41 PM
hello,
i am trying to create a magic 8-ball, my own version of course.
my current document-set consists of two swf-files, the first one of those i want to be there from the start, when you enter the page, and the second one (which there is supposed to be around 20 of) i want to appear and start when you hit a button (which i have not yet created).
all in all i want this:
- enter webpage = one swf-file is looped and there is a button
- clicking the button = the swf is replaced by a randomly picked other swf-file
i am a simple graphic desginer who usually work with print media, so i dont have the code-skills for this project. i have been searching the internet for a whole day without result, please help me!
/karin
coothead
01-04-2012, 10:24 PM
Hi there cookie_,
and a warm welcome to these forums. ;)
Here is an example for you to try...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<base href="http://cl-t056-120cl.privatedns.com/~wwwflas/"> <!--remove this when using your own .swf files -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>display .swf files</title>
<style type="text/css">
body {
margin:0;
background-color:#f0f0f0;
font-family:verdana,arial,hevetica,sans-serif;
}
#wrapper {
width:762px;
padding:15px;
margin:20px auto 0;
box-shadow:#333 5px 5px 10px;
background-color:#fff;
overflow:hidden;
}
.hide {
display:none;
}
#container object {
display:block;
width:760px;
height:400px;
border:1px solid #333;
margin-bottom:15px;
}
#back,#rand,#next {
float:left;
cursor:pointer;
}
#rand,#next {
float:right;
}
#text {
width:600px;
margin:auto;
font-size:12px;
color:#600;
text-align:center;
}
</style>
<script type="text/javascript">
var links=[
'flash-games-jkdsfhjksdhiouiu/3732.swf', /* there is no limit to the array length */
'flash-games-jkdsfhjksdhiouiu/2197.swf',
'flash-games-jkdsfhjksdhiouiu/2355.swf',
'flash-games-jkdsfhjksdhiouiu/3782.swf',
'flash-games-jkdsfhjksdhiouiu/2020.swf',
'flash-games-jkdsfhjksdhiouiu/3000.swf' /* no trailing comma after final item */
];
var displaytext=[
'flash games one',
'flash games two',
'flash games three',
'flash games four',
'flash games five',
'flash games six' /* no trailing comma after final item */
];
var c=0
var el,test,temp;
function init() {
document.getElementById('wrapper').className='';
el=document.getElementById('container');
document.getElementById('back').onclick=function() {
if(c==0) {
c=links.length;
}
c--
displayFiles();
}
document.getElementById('next').onclick=function() {
if(c==links.length-1) {
c=-1;
}
c++;
displayFiles();
}
document.getElementById('rand').onclick=function() {
temp=c;
while(c==temp){
c=Math.floor(Math.random()*links.length);
}
displayFiles();
}
}
function displayFiles() {
test=links[c].substring(links[c].lastIndexOf('.')+1,links[c].length);
document.getElementById('text').innerHTML=displaytext[c];
el.innerHTML=
'<object type="application/x-shockwave-flash" data="'+links[c]+'">'+
'<param name="movie" value="'+links[c]+'">'+
'<\/object>';
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
</script>
</head>
<body>
<div id="wrapper" class="hide">
<div id="container">
<object type="application/x-shockwave-flash" data="flash-games-jkdsfhjksdhiouiu/3732.swf">'+
<param name="movie" value="flash-games-jkdsfhjksdhiouiu/3732.swf">
</object>
</div><!-- end #container -->
<button id="next">next</button>
<button id="back">Back</button>
<button id="rand">Random</button>
<div id="text">flash games one</div>
</div><!-- end #wrapper -->
</body>
</html>
coothead
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.