Responsive Flash Movies
It is not obvious how to make Flash movies compatible with responsive web design. This is a short tutorial on how to accomplish that. An example of a responsive Flash movie created by KoolMoves is shown at:
The full example can be downloaded at:
To view the responsive nature of the Flash animation, slowly decrease the width of the browser window. Below 600 pixels (the width of the starting Flash movie), the Flash movie scales horizontally reflecting the width of the web page. Below 350 pixels, the content switches from the Flash movie to non-Flash content.
The responsive html and css code is exported in KoolMoves using File > Export/Publish Movie > Add Flash Movie to Web Page (Expert Mode) - Copy and paste to existing web page.
The Html page contains four divs:
1) A div with id "container"
2) A div with id "flashcontainer"
3) A div with id "flashbanner", the second argument in the swfobject.embedSWF function
4) A div with id "nonflashcontainer"
Only one of the flashcontainer and nonflashcontainer divs is displayed at any given time. The div is displayed or not displayed depending on the value of the css 'display' attribute. Display:block makes the div display and display:none makes the div not display and not take any space on the web page. The switching which determines which div will display is controlled by a media query. More about that later.
Credit is given to youtube.com/watch?v=3nVWSh5pxZU for some of these design ideas. I did not use the z-index approach since display:none or display:block seemed sufficient to switch Flash content to non-Flash content.
In the css file or the style section of the web page, the nonflashcontainer div width is set to 100% and the height is set to the height of the swf movie. The height can be set to anything. The width of this div is controlled by the width of its parent, the container div. Display is set to 'none' initially.
The flashcontainer div width is set to 100% and the height is set to 100%. The width and height of this div are controlled by its parent, the container div. Display is set to 'block' initially.
A media query switches off display of the flashcontainer and switches on the display of the nonflashcontainer at the arbitrary browser width of 350 pixels.
Another media query controls the width of the container. At a browser width less than 600px (determined by the web page layout and the original width of the Flash movie), the container scales horizontally to the width of its parent element. Otherwise, the width and height of the container are the width and height of the Flash movie.
That is a brief explanation of the miniumum code required to achieve a responsive Flash movie that reverts to a non-Flash display for mobile devices.