<?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>Blogizm &#187; Flash &amp; ActionScript</title>
	<atom:link href="http://blog.aquamedia.com.au/category/development/flash-actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.aquamedia.com.au</link>
	<description>Thoughts and views expressed online by the staff at Aqua Media</description>
	<lastBuildDate>Tue, 08 Jun 2010 07:03:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Watch this space</title>
		<link>http://blog.aquamedia.com.au/2009/10/watch-this-space/</link>
		<comments>http://blog.aquamedia.com.au/2009/10/watch-this-space/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 00:01:33 +0000</pubDate>
		<dc:creator>shsachdeva</dc:creator>
				<category><![CDATA[Flash & ActionScript]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[Flash AS3]]></category>
		<category><![CDATA[Interior design]]></category>
		<category><![CDATA[Website design]]></category>

		<guid isPermaLink="false">http://blog.aquamedia.com.au/?p=273</guid>
		<description><![CDATA[
			
				
			
		

Actionscript 3.0 didn't get a lot of support by those making the move from AS2. But Wonderwall's website has proven its sophistication. Wonderwall is an interior design firm established by Masamichi Katayama. Check out their site. It's fluid and... oh-so sexy! and definitely does justice to their work.
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 15px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F10%2Fwatch-this-space%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F10%2Fwatch-this-space%2F&amp;source=aquamedia&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://wonder-wall.com" target="_blank"><img class="alignnone size-full wp-image-274" style="border: 0pt none;" src="http://blog.aquamedia.com.au/wp-content/uploads/2009/10/WonderWall.png" alt="WonderWall" width="243" height="243" /></a></p>
<p>Actionscript 3.0 didn't get a lot of support by those making the move from AS2. But Wonderwall's website has proven its sophistication. Wonderwall is an interior design firm established by Masamichi Katayama. <a href="http://wonder-wall.com/" target="_blank">Check out their site</a>. It's fluid and... oh-so sexy! and definitely does justice to their work.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aquamedia.com.au/2009/10/watch-this-space/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Switch between Flash Player 9 and 10 on OSX</title>
		<link>http://blog.aquamedia.com.au/2009/09/switch-between-flash-player-9-and-10-on-osx/</link>
		<comments>http://blog.aquamedia.com.au/2009/09/switch-between-flash-player-9-and-10-on-osx/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 03:24:07 +0000</pubDate>
		<dc:creator>Bill Bovopoulos</dc:creator>
				<category><![CDATA[Flash & ActionScript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flash Player 9]]></category>

		<guid isPermaLink="false">http://blog.aquamedia.com.au/?p=173</guid>
		<description><![CDATA[
			
				
			
		
So you have some old sites that you frequently use, and some of them work better with Flash Player 9, or in my instance use an uploader that has not been rewritten for Flash Player 10.
You only need it now and then - what do you do? Can you have both? Yes you can and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 15px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F09%2Fswitch-between-flash-player-9-and-10-on-osx%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F09%2Fswitch-between-flash-player-9-and-10-on-osx%2F&amp;source=aquamedia&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>So you have some old sites that you frequently use, and some of them work better with Flash Player 9, or in my instance use an uploader that has not been rewritten for Flash Player 10.</p>
<p>You only need it now and then - what do you do? Can you have both? Yes you can and here is how I did it.</p>
<p>Everyone is different, so to commence with I have a MacPro running 10.6.1 - you could be on 10.5 on a MacBook - shouldnt really make a difference, but I could be wrong.</p>
<p>You could <a href="http://fpdownload.macromedia.com/get/flashplayer/current/uninstall_flash_player_osx.dmg">download the flash player uninstaller</a>, but when i tried it just sat there wheeling away and basically doing bugger all - so I canned it. Perhaps it's not 10.6 ready...</p>
<p>1) I went to</p>
<blockquote><p>Macintosh HD &gt; Library &gt; Internet Plug-Ins</p></blockquote>
<p>2) Then, I selected the following files:</p>
<blockquote><p>Player Enabler.plugin<br />
Flash Player.plugin<br />
flashplayer.xpt</p></blockquote>
<p>3) I then created a new folder called 'FP10' and put  the 3 files above there. As long as these files are not in the  main folder, your browsers wont find them and thus no flash player.</p>
<p>4) Here is where Adobe make things hard. You have to download the a 200mb download just to get to a 4mb file - thanks Adobe!</p>
<p>Download this</p>
<blockquote><p>http://fpdownload.macromedia.com/get/flashplayer/installers/archive/fp9_archive.zip</p></blockquote>
<p>Then unzip it and go to</p>
<blockquote><p>fp9_archive &gt; 9r246 &gt; flashplayer9r246_ub_mac.dmg</p></blockquote>
<p>That puts two new files into</p>
<blockquote><p>Macintosh HD &gt; Library &gt; Internet Plug-Ins</p>
<p>Flash Player.plugin<br />
flashplayer.xpt</p></blockquote>
<p>And these are the Flash Player 9 pluggins.</p>
<p>Thats it - your now using FP9.</p>
<p>If you want to flip back up to FP10 - put those two files above into a new folder and call it FP9. Place the other 3 files back into the root directory from your F910 folder and your ready to rock again.</p>
<p>Hope that helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aquamedia.com.au/2009/09/switch-between-flash-player-9-and-10-on-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scaling a dynamic background image in proportion using flash</title>
		<link>http://blog.aquamedia.com.au/2009/08/scaling-a-dynamic-background-image-in-proportion-using-flash/</link>
		<comments>http://blog.aquamedia.com.au/2009/08/scaling-a-dynamic-background-image-in-proportion-using-flash/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 06:48:06 +0000</pubDate>
		<dc:creator>Flashnutz</dc:creator>
				<category><![CDATA[Flash & ActionScript]]></category>
		<category><![CDATA[dynamic images]]></category>
		<category><![CDATA[flash image quality]]></category>
		<category><![CDATA[saling dynamic images in flash]]></category>
		<category><![CDATA[scale image in proprtion]]></category>

		<guid isPermaLink="false">http://blog.aquamedia.com.au/2009/08/scaling-a-dynamic-background-image-in-proportion-using-flash/</guid>
		<description><![CDATA[
			
				
			
		
Recently I was playing around with scaling background images and had issues with how the scaling behaved and image quality.  When scaling an image in proportion you want to make sure that the image container is centered to the movie clip it belongs to.
My example below is the scaling code within a stage listener which [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 15px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F08%2Fscaling-a-dynamic-background-image-in-proportion-using-flash%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F08%2Fscaling-a-dynamic-background-image-in-proportion-using-flash%2F&amp;source=aquamedia&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently I was playing around with scaling background images and had issues with how the scaling behaved and image quality.  When scaling an image in proportion you want to make sure that the image container is centered to the movie clip it belongs to.</p>
<p>My example below is the scaling code within a stage listener which will re size the background image according to the stage width &amp; height.</p>
<pre class="actionscript"><span style="color: #0066CC;">Stage</span>.<span style="color: #0066CC;">align</span> = <span style="color: #ff0000;">&quot;TL&quot;</span>;
<span style="color: #0066CC;">Stage</span>.<span style="color: #0066CC;">scaleMode</span> = <span style="color: #ff0000;">&quot;noScale&quot;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//Get Background Image Container Movie Clip Name (instance)</span>
<span style="color: #000000; font-weight: bold;">var</span> backgroundImage:<span style="color: #0066CC;">movieClip</span> = <span style="color: #ff0000;">&quot;MovieClip Instance Name&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Create an object for the stage listener</span>
stageListener:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Create a function for the event you want to listen for</span>
stageListener.<span style="color: #0066CC;">onResize</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//Get the  stage width &amp;amp; height</span>
<span style="color: #000000; font-weight: bold;">var</span> sw:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Stage</span>.<span style="color: #0066CC;">width</span>;
<span style="color: #000000; font-weight: bold;">var</span> sh:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Stage</span>.<span style="color: #0066CC;">height</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//Check to see if image width or height needs adjusting</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>sh / sw<span style="color: #66cc66;">&#41;</span> &amp;gt; <span style="color: #66cc66;">&#40;</span>backgroundImage.<span style="color: #0066CC;">_height</span> / backgroundImage.<span style="color: #0066CC;">_width</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//get image width and adjust height to fit</span>
scale = backgroundImage.<span style="color: #0066CC;">_width</span> / backgroundImage.<span style="color: #0066CC;">_height</span>;
backgroundImage.<span style="color: #0066CC;">_height</span> = sh;
backgroundImage.<span style="color: #0066CC;">_width</span> = sh * scale;
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//get image height and adjust width to fit</span>
scale =backgroundImage.<span style="color: #0066CC;">_height</span> / backgroundImage.<span style="color: #0066CC;">_width</span>;
backgroundImage_width = sw;
backgroundImage.<span style="color: #0066CC;">_height</span> = sw * scale;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//Center the background Image</span>
backgroundImage.<span style="color: #0066CC;">_x</span> = <span style="color: #66cc66;">&#40;</span>sw - backgroundImage.<span style="color: #0066CC;">_width</span><span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">2</span>;
backgroundImage.<span style="color: #0066CC;">_y</span> = <span style="color: #66cc66;">&#40;</span>sh - backgroundImage.<span style="color: #0066CC;">_height</span><span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">2</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span>;
<span style="color: #808080; font-style: italic;">// Add listener for the Stage object</span>
<span style="color: #0066CC;">Stage</span>.<span style="color: #0066CC;">addListener</span><span style="color: #66cc66;">&#40;</span>stageListener<span style="color: #66cc66;">&#41;</span>;</pre>
<p>Now the the simple line of code that makes this work so well is the quality preservation part. Just add this after your dynamic image has loaded.</p>
<pre class="actionscript">backgroundImage.<span style="color: #006600;">forceSmoothing</span> = <span style="color: #000000; font-weight: bold;">true</span>;</pre>
<p>An actionscript 3 version would not be much different to this and should be fairly easy to workout. If your struggling just ask me on my blog <a title="Flashnutz - Helping web developers develop" href="http://www.flashnutz.com" target="_blank">http://www.flashnutz.com</a>.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=7ff26848-a0b3-8854-8ea8-4b83a7a753a3" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.aquamedia.com.au/2009/08/scaling-a-dynamic-background-image-in-proportion-using-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading external images with ActionScript 3</title>
		<link>http://blog.aquamedia.com.au/2009/08/loading-external-images-with-actionscript-3/</link>
		<comments>http://blog.aquamedia.com.au/2009/08/loading-external-images-with-actionscript-3/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 23:55:43 +0000</pubDate>
		<dc:creator>Flashnutz</dc:creator>
				<category><![CDATA[Flash & ActionScript]]></category>
		<category><![CDATA[DisplayObject]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[LoaderInfo]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://blog.aquamedia.com.au/2009/08/loading-external-images-with-actionscript-3/</guid>
		<description><![CDATA[
			
				
			
		
One technique of loading external images is using the Loader class.
It's similar to the URLLoader class but the Loader class loads and displays loaded images and SWF content. The Loader class is a part of the DisplayObject class; it is capable of displaying content as well as loading it.
To load external images using the Loader [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 15px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F08%2Floading-external-images-with-actionscript-3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F08%2Floading-external-images-with-actionscript-3%2F&amp;source=aquamedia&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>One technique of loading external images is using the <strong>Loader</strong> class.</p>
<p>It's similar to the <strong>URLLoader</strong> class but the Loader class loads and displays loaded images and SWF content. The <strong>Loader</strong> class is a part of the <strong>DisplayObject</strong> class; it is capable of displaying content as well as loading it.</p>
<p>To load external images using the <strong>Loader</strong> class, you need to create an object of the <strong>Loader</strong> class.</p>
<blockquote>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> imgLoader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>To load an image into the <strong>Loader Object</strong>, the load method of the <strong>Loader</strong> class is used, along with a <strong>URLRequest</strong>.</p>
<blockquote>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> imgLoader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
imgLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'image.jpg'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>The <strong>LoaderInfo</strong> class also has events and event types that dispatch information about the progress of the load through the <strong>Loader</strong> class.</p>
<p>The code below traces a loaded message after the loader object has completed loading the image.</p>
<blockquote>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> imgLoader:Loader =  <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
imgLoader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListner</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,
loaderCompleteHandler<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> loaderCompleteHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
   <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Image has loaded.'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
imgLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'image.jpg'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>At this point all you have done is loaded in the image to the <strong>Loader</strong> Object. For the loaded image to display you will need to add the <strong>Loader </strong>object to the display list.</p>
<blockquote>
<pre class="actionscript">addChild<span style="color: #66cc66;">&#40;</span>imgLoader<span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>The complete source code looks like this.</p>
<blockquote>
<pre class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> imgLoader:Loader =  <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
imgLoader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListner</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,
loaderCompleteHandler<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> loaderCompleteHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
   <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Image has loaded.'</span><span style="color: #66cc66;">&#41;</span>;
   addChild<span style="color: #66cc66;">&#40;</span>imgLoader<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
imgLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'image.jpg'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>Now your ready to build a preloader in ActionScript 3. <a href="http://www.flashnutz.com/2009/03/building-a-preloader-in-actionscript-3/" target="_blank">Let's build it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aquamedia.com.au/2009/08/loading-external-images-with-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using swfObject with Mootools</title>
		<link>http://blog.aquamedia.com.au/2009/08/using-swfobject-with-mootools/</link>
		<comments>http://blog.aquamedia.com.au/2009/08/using-swfobject-with-mootools/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 23:47:03 +0000</pubDate>
		<dc:creator>Flashnutz</dc:creator>
				<category><![CDATA[Flash & ActionScript]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[embed flash with mootools]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[swfObject]]></category>

		<guid isPermaLink="false">http://blog.aquamedia.com.au/2009/08/using-swfobject-with-mootools/</guid>
		<description><![CDATA[
			
				
			
		
I'm sure most of us use swfObject, which in my opinion is the best option when it comes to embedding flash.
Lately I've been having a lot of fun with mootools  and needed a way to embed flash dynamically. Basically I wanted my flash file to be embedded after a mootools click event was triggered.
So [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 15px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F08%2Fusing-swfobject-with-mootools%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.aquamedia.com.au%2F2009%2F08%2Fusing-swfobject-with-mootools%2F&amp;source=aquamedia&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I'm sure most of us use swfObject, which in my opinion is the best option when it comes to embedding flash.</p>
<p>Lately I've been having a lot of fun with mootools  and needed a way to embed flash dynamically. Basically I wanted my flash file to be embedded after a mootools click event was triggered.</p>
<p>So without further ado..</p>
<pre class="javascript">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//get the div I want to embed my flash into.</span>
<span style="color: #003366; font-weight: bold;">var</span> flashcontainer = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'flashcontainer'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">//set all the flash properties</span>
<span style="color: #003366; font-weight: bold;">var</span> file = <span style="color: #3366CC;">'file.swf'</span>;
<span style="color: #003366; font-weight: bold;">var</span> moviename = <span style="color: #3366CC;">'nameMyFlash'</span>;
<span style="color: #003366; font-weight: bold;">var</span> width = <span style="color: #3366CC;">'640'</span>;
<span style="color: #003366; font-weight: bold;">var</span> height = <span style="color: #3366CC;">'424'</span>;
<span style="color: #003366; font-weight: bold;">var</span> version = <span style="color: #3366CC;">'9'</span>;
<span style="color: #003366; font-weight: bold;">var</span> bgcolor = <span style="color: #3366CC;">'#000000'</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">//create the function that will fuse swfObject with mootools</span>
<span style="color: #003366; font-weight: bold;">var</span> embedFlash = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> so = <span style="color: #003366; font-weight: bold;">new</span> SWFObject<span style="color: #66cc66;">&#40;</span>file, moviename, width, height, version, bgcolor<span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #006600;">addParam</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;quality&quot;</span>, <span style="color: #3366CC;">&quot;high&quot;</span><span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #006600;">addParam</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;align&quot;</span>, <span style="color: #3366CC;">&quot;middle&quot;</span><span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #006600;">addParam</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;play&quot;</span>, <span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #006600;">addParam</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;loop&quot;</span>, <span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #006600;">addParam</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;scale&quot;</span>, <span style="color: #3366CC;">&quot;exactfit&quot;</span><span style="color: #66cc66;">&#41;</span>;
             so.<span style="color: #006600;">addParam</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;allowFullScreen&quot;</span>, <span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #006600;">addVariable</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;variable1&quot;</span>, <span style="color: #3366CC;">&quot;variable 1 value goes here&quot;</span><span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #006600;">addVariable</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;variable2&quot;</span>, <span style="color: #3366CC;">&quot;variable 1 value goes here&quot;</span><span style="color: #66cc66;">&#41;</span>;
	     so.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #66cc66;">&#40;</span>flashcontainer<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//get button by id</span>
<span style="color: #003366; font-weight: bold;">var</span> myButton = $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'mybutton'</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
<span style="color: #009900; font-style: italic;">// create click event to fire my function called &quot;embedFlash()&quot;</span>
myButton.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'click'</span>, embedFlash<span style="color: #66cc66;">&#41;</span>; 
&nbsp;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>And that's it.. Hope it helps....</p>
<blockquote><p>You can download the latest tools used above from the links below:<br />
<a title="MooTools - download release 1.2.3" href="http://mootools.net/download" target="_blank">MooTools - download release 1.2.3</a> or <a title="SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file" href="http://code.google.com/p/swfobject/downloads/list" target="_blank">SWFObject 2.2</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.aquamedia.com.au/2009/08/using-swfobject-with-mootools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
