473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

A question regarding swfobject

mikek12004
200 100+
Trying to build a flash rotator which takes some swf from a db and rotates them.
In the head I have
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.         clock_ads(1);
  3.         function clock_ads(i)
  4.         {
  5.             <?php
  6.             $q1=mysql_query("select * from banners");
  7.             $c1=mysql_num_rows($q1);
  8.             if ($c1>0) //got banners and ok to show
  9.             {
  10.                 $maxy=0;
  11.                 //check if only one entry
  12.                 for ($j=1;$j<=$c1;$j++)
  13.                 {
  14.                     $q2=mysql_query("select * from banners where banorder='$j'");
  15.                     $r2=mysql_fetch_array($q2);
  16.                     $file="banners/".$r2[1];
  17.                     $size=getimagesize($file);
  18.                     if ($size[1]>$maxy) $maxy=$size[1];
  19.                     $life=$r2[3];
  20.                     if ($j==1) echo "if"; else echo "else if";
  21.                     ?>
  22.                     (i=='<?php echo $j;?>')
  23.                     {
  24.                         //check to see how we will display the ad based on the type (flash or image) 
  25.  
  26.                         if ( ("<?php echo $r2[1];?>".search(/.swf/i))>0 )
  27.                         {
  28.  
  29.                             swfobject.embedSWF("<?php echo $file;?>", "myContent", "<?php echo $size[0];?>", "<?php echo $size[1];?>", "9.0.0");
  30.  
  31.                         }
  32.                         else
  33.                         {
  34.  
  35.                             document.getElementById("myContent").innerHTML="<img border='0' src='<?php echo $file;?>' />";
  36.  
  37.                         }
  38.                         if (<?php echo $c1?>!='1')
  39.                             setTimeout("clock_ads(<?php echo $j+1;?>)",<?php echo $life;?>);    
  40.                     }
  41.                     <?php    
  42.                 }
  43.             }//if ($c1>0) //got banners and ok to show
  44.             ?>
  45.             if (i><?php echo $c1;?>) clock_ads(1);
  46.         }
  47.         </script>    
  48.  
and in the body a
Expand|Select|Wrap|Line Numbers
  1. <div id="myContent">
  2.                                                             <h2><?php echo GET_FLASH;?></h2>
  3.                                                             <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
  4.                                                             </div> 
  5.  
when I have only swf it works ok but when I also use images I get an error that
mycontent is null meaning that it cannot find the div, as I see it the
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("myContent").innerHTML="<img border='0' src='<?php echo $file;?>' />";
  2.  
is for some reason relating to the swf wrong logic any help?

PS Even when I moved the script below the div in the body the image was shown once and only when it was shown before a swf after that it was simply ignored and the page showed only the swfs
Oct 15 '09 #1
2 1757
mikek12004
200 100+
a bit of further explanation about the code, all it does is to generate a javascript to do the job e.g. an image ELNAVI.jpg and after that 2 swf we have this

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.         clock_ads(1);
  3.         function clock_ads(i)
  4.         {
  5.             if    (i=='1')
  6.             {
  7.                 //check to see how we will display the ad based on the type (flash or image)     
  8.                 if ( ("ELNAVI.jpg".search(/.swf/i))>0 )
  9.                 {
  10.                     swfobject.embedSWF("banners/ELNAVI.jpg", "myContent", "160", "37", "9.0.0");
  11.                 }
  12.                 else
  13.                 {
  14.                     document.getElementById("myContent").innerHTML="<img border='0' src='banners/ELNAVI.jpg' />'";
  15.                 }
  16.                 if (3!='1')
  17.                     setTimeout("clock_ads(2)",8000);    
  18.             }
  19.             else if    (i=='2')
  20.             {
  21.             //check to see how we will display the ad based on the type (flash or image) 
  22.                 if ( ("gmlogoA.swf".search(/.swf/i))>0 )
  23.                 {
  24.                     swfobject.embedSWF("banners/gmlogoA.swf", "myContent", "779", "136", "9.0.0");
  25.                 }
  26.                 else
  27.                  {
  28.                     document.getElementById("myContent").innerHTML="<img border='0' src='banners/gmlogoA.swf' />'";
  29.                 }
  30.                 if (3!='1')
  31.                     setTimeout("clock_ads(3)",5000);    
  32.                 }
  33.                 else if    (i=='3')
  34.                 {
  35.                     //check to see how we will display the ad based on the type (flash or image) 
  36.                     if ( ("alba468x60msc150609.swf".search(/.swf/i))>0 )
  37.                     {
  38.                         swfobject.embedSWF("banners/alba468x60msc150609.swf", "myContent", "468", "60", "9.0.0");
  39.                     }
  40.                     else
  41.                     {    
  42.                         document.getElementById("myContent").innerHTML="<img border='0' src='banners/alba468x60msc150609.swf' />'";    
  43.                     }
  44.                     if (3!='1')
  45.                         setTimeout("clock_ads(4)",5000);    
  46.                 }
  47.                 if (i>3) clock_ads(1);
  48.             }
  49. </script>  
Oct 16 '09 #2
acoder
16,027 Expert Mod 8TB
See line 14:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("myContent").innerHTML="<img border='0' src='banners/ELNAVI.jpg' />'"
You have an extraneous ' (single quote).
Oct 24 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Francis Lavoie | last post by:
Hello I have some questions regarding webframework, I must say that I quite lost and these questions are basicly to help me understand the way it work. I have some knowledge with PHP and JSP....
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
1
by: dragze | last post by:
Hi, On one of the pages of my site i use two javascripts, one makes transparency of png's work in IE, and the other embeds a flash player. Now use one of the scripts it works fine, use both and...
3
by: K. | last post by:
Hello! I have a problem with javascript script called: SWFObject. I have a web page which displays on IE 7.0. i Firefox in a good way. All flash objects are displayed on a web page. The problem...
49
anfetienne
by: anfetienne | last post by:
is it possible to add php array to vars in the swfobject code?
3
by: yogarajan | last post by:
hi friend this is my code <script type="text/javascript"> // <!]> </script> it is working fine for (open file) file:///D:/WebSite4/swfobject/swfobject1-5/fullpage.html
0
by: jay11 | last post by:
Hello peeps I am trying to run a banner with SWFObject from within PHP/Mambo. I have two others SWF in the same page, so I know it works. Also checked the Developer tool in Chrome and saw that...
0
by: jeddiki | last post by:
I am reading up on this swfobject which uses javascript to embed the swf files. They say that I need to have adobe flash player 9.0 Well I was going to use Flowplayer. Does this mean that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.