<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>In Flagrante Delicto! &#187; Embed</title>
	<atom:link href="http://inflagrantedelicto.memoryspiral.com/tag/embed/feed/" rel="self" type="application/rss+xml" />
	<link>http://inflagrantedelicto.memoryspiral.com</link>
	<description>Joseph Labrecque: Flash Platform Developer - Multidisciplinary Digital Artist - Adobe Education Leader</description>
	<lastBuildDate>Wed, 01 Sep 2010 15:48:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Rendering Flash Content with Dynamic WMODE Attributes &#8211; Revisited</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2009/11/rendering-flash-content-with-dynamic-wmode-attributes-revisited/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rendering-flash-content-with-dynamic-wmode-attributes-revisited</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2009/11/rendering-flash-content-with-dynamic-wmode-attributes-revisited/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 04:39:14 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Embed]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=1191</guid>
		<description><![CDATA[Screw Internet Explorer! This is one of the many reasons I prefer to avoid having a browser render anything at all for me. Can&#8217;t trust it! Better to just take care of these things before it even hits the browser: &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2009/11/rendering-flash-content-with-dynamic-wmode-attributes-revisited/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Screw Internet Explorer!  This is one of the many reasons I prefer to avoid having a browser render anything at all for me.  Can&#8217;t trust it!  Better to just take care of these things before it even hits the browser:</p>
<p><em>Java JSP example</em></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> embedCode1 <span style="color: #339933;">=</span> item.<span style="color: #006633;">getEmbedCode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">String</span> expression1 <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&gt;&lt;param&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> replacement1 <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&gt;&lt;param name=<span style="color: #000099; font-weight: bold;">\&quot;</span>wmode<span style="color: #000099; font-weight: bold;">\&quot;</span> value=<span style="color: #000099; font-weight: bold;">\&quot;</span>transparent<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;param&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> embedCode2 <span style="color: #339933;">=</span> embedCode1.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span>expression1, replacement1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">String</span> expression2 <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;embed &quot;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> replacement2 <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;embed wmode=<span style="color: #000099; font-weight: bold;">\&quot;</span>transparent<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> embedCodeFinal <span style="color: #339933;">=</span> embedCode2.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span>expression2, replacement2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;embedHolder&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;%=</span>embedCodeFinal<span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>What am I talking about? You can read up on my <a href="http://inflagrantedelicto.memoryspiral.com/2009/09/rendering-flash-content-with-dynamic-wmode-attributes/">original article</a> if it pleases you.</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2009/11/rendering-flash-content-with-dynamic-wmode-attributes-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rendering Flash Content with Dynamic WMODE Attributes</title>
		<link>http://inflagrantedelicto.memoryspiral.com/2009/09/rendering-flash-content-with-dynamic-wmode-attributes/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rendering-flash-content-with-dynamic-wmode-attributes</link>
		<comments>http://inflagrantedelicto.memoryspiral.com/2009/09/rendering-flash-content-with-dynamic-wmode-attributes/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 21:46:18 +0000</pubDate>
		<dc:creator>Joseph Labrecque</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Embed]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://inflagrantedelicto.memoryspiral.com/?p=1049</guid>
		<description><![CDATA[We all know that to have Javascript menus and such overlay embedded Flash content, that we need to set the WMODE parameter of our embed code to &#8220;opaque&#8221; or &#8220;transparent&#8221;. This is usually pretty simple if you are generating the &#8230; <a href="http://inflagrantedelicto.memoryspiral.com/2009/09/rendering-flash-content-with-dynamic-wmode-attributes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We all know that to have Javascript menus and such overlay embedded Flash content, that we need to set the <a href="http://kb2.adobe.com/cps/155/tn_15523.html">WMODE parameter</a> of our embed code to &#8220;opaque&#8221; or &#8220;transparent&#8221;.  This is usually pretty simple if you are generating the embed code yourself through <a href="http://code.google.com/p/swfobject/">SWFObject</a>, or even simply through HTML.  </p>
<p>Here&#8217;s the thing&#8230; what if your application allows users to embed SWF content from <a href="http://www.youtube.com/">YouTube</a>, <a href="http://vimeo.com/">Vimeo</a>, and other such services?  What if your system generates little edit menus that happen to overlap such content?  These services generally do not include the proper WMODE values to allow dynamic overlays.  If you are just accepting SWF embed content, it&#8217;s a simple task to just parse the embed string and store the necessary values in your application to spit back out later using your own embed code formatting.  What if there are just too many unknowns about the content your users may need to embed in the application?  What if you also accept plain HTML embeds from services like <a href="http://twitter.com/">Twitter</a> and <a href="http://www.facebook.com/">Facebook</a> or other non-SWF content that you cannot parse attributes from so predictably? Then you need to do some more tricks to get that WMODE parameter set for any potential Flash content!</p>
<p>I use <a href="http://jquery.com/">jQuery</a> quite a bit when I absolutely need to deal with Javascript and like how it keeps the code from getting out of hand.  It also provides a ton of extra functionality that is really useful when trying to identify certain elements in your HTML document for manipulation.  I&#8217;d already tagged any user embed containing elements with a class of &#8220;embedHolder&#8221;, so using jQuery it would be super simple to identify all user embedded elements.  So the original plan was to use both append() and attr() to modify any object or embed tag nested within any of these tagged container elements in order to add the necessary WMODE parameters:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder object&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder embed&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;wmode&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;transparent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This doesn&#8217;t work though!  It will certainly go through and modify the elements as needed, but since the SWF content has already been drawn into the viewport, the WMODE parameters are ignored.  Thankfully, jQuery is super-awesome and includes both a show() and a hide() method.  When you use hide() on an element, it will remove it from the viewport.  Using show() will make it visible again.  this effectively forces the browser to reload and redraw the SWF content, this time taking the WMODE changes into account perfectly.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder object&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder embed&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;wmode&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;transparent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//a bunch of other code you may have</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Awesome!</p>
<hr />
<p>UPDATE 1: Errr&#8230; awesome in some browsers.  As Josh points out below, the actual behavior differs quite a bit between browsers.  No problem- I have a plan and will update this tomorrow with a solution. (hopefully!)</p>
<p>UPDATE 2: Yeah- IE is the only problem browser I&#8217;ve come across.  Surprised?  No.</p>
<p>UPDATE 3: Here is a solution for all browsers (even IE!):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder object&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder embed&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;wmode&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;transparent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.embedHolder&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>
		<span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> cont <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;div class=&quot;embedHolder&quot;&gt;'</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replaceWith</span><span style="color: #009900;">&#40;</span>cont<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now we are explicitly removing elements from the DOM and then reloading them into the same node, forcing the browser to redraw the SWF and activate the proper WMODE.</p>
]]></content:encoded>
			<wfw:commentRss>http://inflagrantedelicto.memoryspiral.com/2009/09/rendering-flash-content-with-dynamic-wmode-attributes/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
