28 de junio de 2013

Flash responsivo

We recommend not to use flash (swf) in Joomla 3, because Flash is not supported in many mobile devices. If you nevertheless want to use Flash this is a technique to create responsive flash objects.

Flash code
The w3C flasshcode is without "embed". Create 2 divs's around the flash object, each with a unique class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="objectcontainer">
  <div class="objectwrapper">
  
    <object width="375" height="241"
        data="images/CIAA_Model.swf"
        type="application/x-shockwave-flash">
      <param name="quality" value="best" />
      <param name="wmode" value="opaque" />
      <param name="base" value="/joomlacss/" />
      <param name="src" value="images/CIAA_Model.swf" />
    </object>
  
  </div>
</div>

CSS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
div.objectcontainer {
    max-width: 375px;
    width: 100%;
}
div.objectcontainer div.objectwrapper {
    height: 0;
    padding: 0 0  64.26666667% 0;
    position: relative;
}
div.objectwrapper object {
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
}

The outer div (=div.objectcontainer) has a width of 1000% and a max-width of the original flash object (375px).
The inner div (=div.objectwrapper) has a height of 0, a position relative and a bottom padding of a percentage height/width (=241 / 375 *100% = 64.26666667%).

With this CSS the flash object is responsive and will be proportionallly redoced in size less than 375px.