4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-flash-Component'>/**
19 </span> * @class Ext.flash.Component
20 * @extends Ext.Component
22 * A simple Component for displaying an Adobe Flash SWF movie. The movie will be sized and can participate
23 * in layout like any other Component.
25 * This component requires the third-party SWFObject library version 2.2 or above. It is not included within
26 * the ExtJS distribution, so you will have to include it into your page manually in order to use this component.
27 * The SWFObject library can be downloaded from the [SWFObject project page](http://code.google.com/p/swfobject)
28 * and then simply import it into the head of your HTML document:
30 * <script type="text/javascript" src="path/to/local/swfobject.js"></script>
34 * This component allows several options for configuring how the target Flash movie is embedded. The most
35 * important is the required {@link #url} which points to the location of the Flash movie to load. Other
36 * configurations include:
38 * - {@link #backgroundColor}
40 * - {@link #flashVars}
41 * - {@link #flashParams}
42 * - {@link #flashAttributes}
46 * var win = Ext.widget('window', {
47 * title: "It's a tiger!",
63 * Adobe provides a tool called [Express Install](http://www.adobe.com/devnet/flashplayer/articles/express_install.html)
64 * that offers users an easy way to upgrade their Flash player. If you wish to make use of this, you should set
65 * the static EXPRESS\_INSTALL\_URL property to the location of your Express Install SWF file:
67 * Ext.flash.Component.EXPRESS_INSTALL_URL = 'path/to/local/expressInstall.swf';
69 * @docauthor Jason Johnston <jason@sencha.com>
71 Ext.define('Ext.flash.Component', {
72 extend: 'Ext.Component',
73 alternateClassName: 'Ext.FlashComponent',
74 alias: 'widget.flash',
76 <span id='Ext-flash-Component-cfg-flashVersion'> /**
77 </span> * @cfg {String} flashVersion
78 * Indicates the version the flash content was published for. Defaults to <tt>'9.0.115'</tt>.
80 flashVersion : '9.0.115',
82 <span id='Ext-flash-Component-cfg-backgroundColor'> /**
83 </span> * @cfg {String} backgroundColor
84 * The background color of the SWF movie. Defaults to <tt>'#ffffff'</tt>.
86 backgroundColor: '#ffffff',
88 <span id='Ext-flash-Component-cfg-wmode'> /**
89 </span> * @cfg {String} wmode
90 * The wmode of the flash object. This can be used to control layering. Defaults to <tt>'opaque'</tt>.
91 * Set to 'transparent' to ignore the {@link #backgroundColor} and make the background of the Flash
96 <span id='Ext-flash-Component-cfg-flashVars'> /**
97 </span> * @cfg {Object} flashVars
98 * A set of key value pairs to be passed to the flash object as flash variables. Defaults to <tt>undefined</tt>.
101 <span id='Ext-flash-Component-cfg-flashParams'> /**
102 </span> * @cfg {Object} flashParams
103 * A set of key value pairs to be passed to the flash object as parameters. Possible parameters can be found here:
104 * http://kb2.adobe.com/cps/127/tn_12701.html Defaults to <tt>undefined</tt>.
107 <span id='Ext-flash-Component-cfg-flashAttributes'> /**
108 </span> * @cfg {Object} flashAttributes
109 * A set of key value pairs to be passed to the flash object as attributes. Defaults to <tt>undefined</tt>.
112 <span id='Ext-flash-Component-cfg-url'> /**
113 </span> * @cfg {String} url
114 * The URL of the SWF file to include. Required.
117 <span id='Ext-flash-Component-cfg-swfWidth'> /**
118 </span> * @cfg {String/Number} swfWidth The width of the embedded SWF movie inside the component. Defaults to "100%"
119 * so that the movie matches the width of the component.
123 <span id='Ext-flash-Component-cfg-swfHeight'> /**
124 </span> * @cfg {String/Number} swfHeight The height of the embedded SWF movie inside the component. Defaults to "100%"
125 * so that the movie matches the height of the component.
129 <span id='Ext-flash-Component-cfg-expressInstall'> /**
130 </span> * @cfg {Boolean} expressInstall
131 * True to prompt the user to install flash if not installed. Note that this uses
132 * Ext.FlashComponent.EXPRESS_INSTALL_URL, which should be set to the local resource. Defaults to <tt>false</tt>.
134 expressInstall: false,
136 <span id='Ext-flash-Component-property-swf'> /**
137 </span> * @property swf
138 * @type {Ext.Element}
139 * A reference to the object or embed element into which the SWF file is loaded. Only
140 * populated after the component is rendered and the SWF has been successfully embedded.
143 // Have to create a placeholder div with the swfId, which SWFObject will replace with the object/embed element.
144 renderTpl: ['<div id="{swfId}"></div>'],
146 initComponent: function() {
148 if (!('swfobject' in window)) {
149 Ext.Error.raise('The SWFObject library is not loaded. Ext.flash.Component requires SWFObject version 2.2 or later: http://code.google.com/p/swfobject/');
152 Ext.Error.raise('The "url" config is required for Ext.flash.Component');
158 <span id='Ext-flash-Component-event-success'> /**
159 </span> * @event success
160 * Fired when the Flash movie has been successfully embedded
161 * @param {Ext.flash.Component} this
165 <span id='Ext-flash-Component-event-failure'> /**
166 </span> * @event failure
167 * Fired when the Flash movie embedding fails
168 * @param {Ext.flash.Component} this
174 onRender: function() {
177 swfId = me.getSwfId();
179 me.renderData.swfId = swfId;
181 me.callParent(arguments);
184 allowScriptAccess: 'always',
185 bgcolor: me.backgroundColor,
190 allowedDomain: document.location.hostname
193 new swfobject.embedSWF(
199 me.expressInstall ? me.statics.EXPRESS_INSTALL_URL : undef,
203 Ext.bind(me.swfCallback, me)
207 <span id='Ext-flash-Component-method-swfCallback'> /**
209 * The callback method for handling an embedding success or failure by SWFObject
210 * @param {Object} e The event object passed by SWFObject - see http://code.google.com/p/swfobject/wiki/api
212 swfCallback: function(e) {
215 me.swf = Ext.get(e.ref);
217 me.fireEvent('success', me);
220 me.fireEvent('failure', me);
224 <span id='Ext-flash-Component-method-getSwfId'> /**
225 </span> * Retrieve the id of the SWF object/embed element
227 getSwfId: function() {
228 return this.swfId || (this.swfId = "extswf" + this.getAutoId());
231 onSuccess: function() {
232 // swfobject forces visiblity:visible on the swf element, which prevents it
233 // from getting hidden when an ancestor is given visibility:hidden.
234 this.swf.setStyle('visibility', 'inherit');
237 onFailure: Ext.emptyFn,
239 beforeDestroy: function() {
243 swfobject.removeSWF(me.getSwfId());
251 <span id='Ext-flash-Component-static-property-EXPRESS_INSTALL_URL'> /**
252 </span> * Sets the url for installing flash if it doesn't exist. This should be set to a local resource.
253 * See http://www.adobe.com/devnet/flashplayer/articles/express_install.html for details.
257 EXPRESS_INSTALL_URL: 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressInstall.swf'