Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Flash Swfobject 2.1 keep swf centered

Posted on 2008-10-03
2
Medium Priority
?
751 Views
Last Modified: 2012-05-05
Hi

I am having some real issues getting this swf to do what i want.

The Swf is 1980 by 660 and i need to keep it centered at all times whatever the screen size, especially when screen width is less than the swf width.

I cant work out if it is a css thing or a param/attribute thing.

Any suggestions would be much appreciated.

Many thanks

--s--
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        
		<style type="text/css"> 
        <!--
        body {
        background:#87ADAE url(images/bg.gif) repeat-x;
		margin:0;
        }
         
        #alternativeContent {
		
        }
		
        #flashContent{
		
        }
		
        --> 
        </style> 
        
        
        
		<script type="text/javascript" src="js/swfobject.js"></script>
		<script type="text/javascript">
			var flashvars = {};
			
			var params = {};
			params.quality = "high";
			params.scale = "noscale";
			params.salign = "t";
			params.allowscriptaccess = "always";
			params.allowfullscreen = "false";
			
			var attributes = {};
			attributes.id = "flashContent";
			attributes.styleclass = "flashContent";	
			attributes.align = "center";
					
			swfobject.embedSWF("media/dv_v4.swf", "alternativeContent", "1980", "660", "9.0.0", false, flashvars, params, attributes);
		</script>
        
        
        
        
	</head>
	<body>
        
		<div id="alternativeContent">
			    <img src="images/no-flash.jpg" width="1033" height="600" border="0" usemap="#Map"/>
			    
			    <map name="Map" id="Map">
			        <area shape="rect" coords="854,60,1013,99" href="http://www.adobe.com/go/getflashplayer" target="_blank" alt="Get Adobe Flash Player" />
			        <area shape="rect" coords="30,555,223,570" href="mailto:daphne@link.com" />
			        <area shape="rect" coords="33,121,1008,539" href="http://www.link.com/" alt="Go to the my flash site" />
			    </map>
		</div>
        
	</body>
</html>

Open in new window

0
Comment
Question by:socross
2 Comments
 
LVL 13

Accepted Solution

by:
crooksy88 earned 2000 total points
ID: 22632418
The code below sets the size parameters to 100% which will keep the swf centred.

Note that anything outside your flash canvas area will also now be displayed so you will have to mask these within Flash
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1"> 
<title></title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
 
<body bgcolor= #000000 leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
<div id="flashcontent">
<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW">This website requires the Flash 8 plug-in to be installed.
Click here to get Flash</a></div>
<script type="text/javascript">
var so = new SWFObject("file.swf", "file", "100%", "100%", "8", "#000000", true); 
so.addParam("scale", "noscale");
so.addParam("quality", "high");
so.write("flashcontent");
</script></body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:socross
ID: 22632535
Perfect, I missed the width 100% added it to my code and job done.

Thanks alot.

--s--
swfobject.embedSWF("media/dv_v4.swf", "alternativeContent", "100%", "660", "9.0.0", false, flashvars, params, attributes);
                

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question