Flash Tutorials - Herong's Tutorial Examples - Version 3.02, by Dr. Herong Yang
Playing Flash with Nested "object" Elements
This section provides a tutorial example on how to create nested 'object' elements to allow both Firefox and IE to play a Flash file correctly.
After going through those tests presented in previous sections, we now know that there are 2 primary ways to use the "object" element to play Flash files:
The question is then, how can we create an "object" element that works on both IE and Firefox?
The answer is using nested "object" elements as shown in the following example, object_object_swf.html:
<html><body> <!-- object_object_swf.html - Copyright (c) 2014, HerongYang.com, All Rights Reserved. --> <p>Flash with nested "object" elements:</p> <table border="1" cellpadding="0" cellspacing="0"> <tr><td> <!-- The outer "object" is for IE and ActiveX based browsers --> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="217" height="85"> <param name="movie" value="yahoo.swf"/> <!-- The inner "object" is for Firefox and other browsers --> <object data="yahoo.swf" width="217" height="85"> <!-- The message is any browser failing on both --> Halloween on Yahoo! </object> </object> </td></tr> </table> </body></html>
This example code works perfectly on both Firefox and IE, because all browsers follow 2 rules when rendering "object" elements:
When IE opens the example code, it will render the outer "object" element and ignore the element content which is the inner "object" element.
When Firefox opens the example code, it will fail on the outer "object" element first. It will then render the element content which is the inner "object" element.
If you are reading the Web version of this book,
you should be able to see the above Flash code played below.
Otherwise, you will see a static image below.
Last update: 2014.
Table of Contents