Results 1 to 2 of 2

Thread: loading random swf-files with a button

  1. #1
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default loading random swf-files with a button

    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

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,094
    Thanks
    1
    Thanked 205 Times in 201 Posts

    Default

    Hi there cookie_,

    and a warm welcome to these forums.

    Here is an example for you to try...
    Code:
    
    
    <!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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •