Thursday, December 8, 2011

Flash: Disabling default scaling of your flash file

I was browsing through my previous post and I was looking at the demo that I had created. There seems to be something amiss in the example that I had created. After taking a good look at it, I realised that there were white borders appearing on the left and right side of my flash file. and on top of it, the text of the Google Map Component appears to be very blur. I also realise that all of the above were caused by the default property of scaling the flash file. Hence, I have thrown in a fix to it and everything looks much better now. :)

I only make a minor change into the html file and the following would be the source file for the html file.
<style type="text/css">
body {margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}
#flashContent {width:100%;height:100%;}
   <!-- Include support librarys first -->  
  <script type="text/javascript" src="jsScript/swfobject.js"></script>
  <script type="text/javascript" src="jsScript/swfforcesize.js"></script>      
  <script type="text/javascript" src="jsScript/swfaddress.js?tracker=null"></script>    

    <div id="fb-root"></div>
    <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
    <tr><td align="center">
    <div id="flashContent">
         <h1>You need at least Flash Player 10.0 to view this page.</h1>
                <p><a href=""><img src="" alt="Get Adobe Flash player" /></a></p>
  <script type="text/javascript">
   function createSWF(){
    var now=new Date();
    now = Date.UTC(now.getYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds());
    var swfURL = "swf/Main.swf?date=" + now;
    var flashvars = {};
    //Remove default scaling of the flash file
    var params = {scale :"noscale"};
    var attributes = {}; = "flashContent";
    swfobject.embedSWF(swfURL, "flashContent", "100%", "100%", "10.0.2", null, flashvars, params, attributes);    
     var obj = document.getElementById("flashContent");
      var forcesize = new SWFForceSize(obj, 800, 600);
* Click here to view the previous example.
^ Click here to view the demo of this example.
~ Click here for the source files of this demo.

By the way, if you are adding or embedding a Flash file into a webpage or website, I would highly recommend you to use the Javascript classes known as SWFObject to add or embed your Flash file into a webpage or website.

- Click here to find out more about SWFObject.

No comments:

Post a Comment