<?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>Jon&#039;s Blog &#187; flash</title>
	<atom:link href="http://bombdiggity.net/blog/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://bombdiggity.net/blog</link>
	<description>Ramblings of a php coder</description>
	<lastBuildDate>Fri, 14 May 2010 17:36:14 +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>SWFUpload with Ext JS Buttons</title>
		<link>http://bombdiggity.net/blog/2009/01/16/swfupload-with-ext-js-buttons/</link>
		<comments>http://bombdiggity.net/blog/2009/01/16/swfupload-with-ext-js-buttons/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 14:52:12 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[swfupload]]></category>

		<guid isPermaLink="false">http://www.bombdiggity.net/blog/?p=78</guid>
		<description><![CDATA[For the longest time I am have been using Ext JS to write the Administration Tools for the Indianapolis Motor Speedway and the Indy Racing League where I work. Some of the tools required uploading of large files to where I would use the SWFUpload library to achieve this functionally. With the introduction of Flash [...]]]></description>
			<content:encoded><![CDATA[<p>For the longest time I am have been using <a href="http://extjs.com/" title="Ext JS">Ext JS</a> to write the Administration Tools for the Indianapolis Motor Speedway and the Indy Racing League where I work.  Some of the tools required uploading of large files to where I would use the <a href="http://swfupload.org/" title="SWFUpload">SWFUpload</a> library to achieve this functionally.  With the introduction of Flash 10 to where you can not have JavaScript call the method to open the dialog box any more this presented a problem.  The generally accepted workaround is to have the flash object be transparent and over the button but this doesn&#8217;t allow the button to have events or allow you to do hover overs and the such, Until Now.<br />
<span id="more-78"></span><br />
I spent a few hours working on this to get the example working to where you still have the basic functionally of the button (events and hover) but you still get the flash dialog to open.  What I did to achieve this is place the flash object over the underlying &lt;button&gt; that is in the Ext Button.</p>
<p>Here is my html code:</p>
<pre class="brush: html">
&lt; !DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;&gt;
        &lt;title&gt;Flash Ext JS Button&lt;/title&gt;
        &lt;link href=&quot;/js/ext2.2/css/ext-all.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;/js/ext2.2/ext-base.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;/js/ext2.2/ext-all.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;/js/swfupload/swfupload.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;/js/swfupload/plugins/swfupload.swfobject.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;/js/swfupload/plugins/swfupload.queue.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;./button.js&quot;&gt;&lt;/script&gt;
        &lt;style type=&quot;text/css&quot;&gt;
            .swfupload {
                position: absolute;
                z-index: 1;
            }
        &lt;/style&gt;
    &lt;/meta&gt;&lt;/head&gt;
    &lt;body&gt;
        &lt;div style=&quot;padding: 20px;&quot;&gt;
           &lt;div id=&quot;btnHolder&quot;&gt;&lt;/div&gt;
           &lt;br /&gt;&lt;br /&gt;
           &lt;div id=&quot;btnEvent&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>button.js file:</p>
<pre class="brush: js">
Ext.onReady(function(){
    new Ext.Button({
        renderTo: &#039;btnHolder&#039;,
        id : &#039;btnClick&#039;,
        text: &#039;Open Download Dialog&#039;,
        listeners : {
            &#039;click&#039; : function(){
                Ext.fly(&#039;btnEvent&#039;).update(&#039;Button Click Fired&#039;);
                (function(){
                    Ext.fly(&#039;btnEvent&#039;).update();
                }).defer(2000);
            },
            &#039;render&#039; : function(btn) {
                Ext.get(&#039;btnClick&#039;).child(&#039;em&#039;).insertFirst({tag: &#039;span&#039;, id: &#039;btnUploadHolder&#039;});
                SWFUpload.onload = function () {
                      var settings = {
                          flash_url : &quot;/js/swfupload/swfupload.swf&quot;,
                          upload_url: &quot;/upload/postfile&quot;,	// Relative to the SWF file
                          file_size_limit : &quot;20 MB&quot;,
                          file_types : &quot;*.jpg&quot;,
                          file_types_description : &quot;Image Files&quot;,
                          file_upload_limit : 20,
                          file_queue_limit : 20,
                          debug: false,

                          // Button Settings
                          button_placeholder_id : &quot;btnUploadHolder&quot;,
                          button_width: Ext.get(&#039;btnClick&#039;).child(&#039;button&#039;).getWidth(),
                          button_height: Ext.get(&#039;btnClick&#039;).child(&#039;button&#039;).getHeight(),
                          button_cursor : SWFUpload.CURSOR.HAND,
                          button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,

                          // SWFObject settings
                          minimum_flash_version : &quot;9.0.28&quot;
                      };

                      swfu = new SWFUpload(settings);
                  };
            }
        }
    });
});
</pre>
<p>Basically what I do is have it insert the flash object on the render event of the button or the Ext Component that contains the button I want to render it to.</p>
<p><a href="http://code.bombdiggity.net/extbutton/" title="Working Sample">Click here for a working sample</a></p>
<p>Let me know of any questions in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://bombdiggity.net/blog/2009/01/16/swfupload-with-ext-js-buttons/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
