Stop resized SWF problem

Discussion in 'JavaScript' started by Tony Brar, Feb 26, 2013.

  1. #1
    Hi guys,

    I have been using the extremely useful SWFObject for including SWFs on my page.
    Google Code project page: https://code.google.com/p/swfobject/
    Documentation: https://code.google.com/p/swfobject/wiki/documentation
    Obviously, I need all of the SWFs across my website to be one size, in this case 800x650.
    But when I resize it, the SWF ends up having problems like this:
    swfbreaking.png
    Notice the platform (it's a game) sticking out the side of the SWF.
    How do I resize the SWF so that the whole thing, and all the objects in the SWF, are resized evenly?

    Thanks,
    -Tony
     
    Tony Brar, Feb 26, 2013 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    SWFObject is a relic from a decade past at BEST, an outdated train wreck of javascript for NOTHING at worst. I'd advise just writing in the object tag normally without any of that garbage -- using a IE conditional to add the CLSID copy.

    Just replace every time you are using that steaming pile of **** with the actual proper markup:
    <!--[if IE ]>
    	<object
    		type="application/x-shockwave-flash"
    		classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    		width="800" height="650"
    	>
    <![endif]-->
    <!--[if !IE]>-->
    	<object
    		type="application/x-shockwave-flash"
    		data="video.swf"
    		width="800" height="650"
    	>
    <!--<![endif]-->
    	<param name="movie" value="video.swf" />
    	<param name="quality" value="high" />
    	<param name="bgcolor" value="#000000" />
    	<p>
    		<a href="http://get.adobe.com/flashplayer/">
    			Adobe Flash Player
    		</a> is required to view this content.
    	</p>
    </object>
    Code (markup):
    Good javascript ENHANCES markup, it should NEVER be used to supplant it.

    If the ACTUAL Object element in the DOM is being resized, there is no reason for the behavior you are showing to happen or for it even be possible for it to escape it's container.

    Just a word of warning, SOME flash files are written to specific aspect ratios, and if you set width and height on object you will FORCE the aspect and or chop things differently. This can cause a great number of flash files to behave quite poorly when resized... for those you need to do the math to change the height as appropriate to the width so as to preserve the original 'designed' aspect. That could be what's making something peek out on one side or render funny instead of chopping off as expected -- you might be seeing the 'over-render' part of the buffer due to trying to show wide-screen content in a 4:3 box. SOMETIMES you can get away with not stating a height and leaving it to the default auto behavior, but some files don't report that data to the plugin (or the plugin to the browser for that matter) properly.
     
    Last edited: Feb 26, 2013
    deathshadow, Feb 26, 2013 IP
  3. Tony Brar

    Tony Brar Active Member

    Messages:
    220
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #3
    So I can't really stop the problem from happening and I'll have to work around it?
    On newgrounds.com's upload game page, there is no certain size that your game has to be:
    http://www.newgrounds.com/projects/games/submit
    And, on pages with games, the game fits inside a little box, even if the proportions are different.
    Is there a way I can scale the SWF down while maintaining the aspect ratio?

    Thanks,
    -Tony
     
    Tony Brar, Feb 28, 2013 IP