4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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-method-constructor'><span id='Ext-flash-Component'>/**
19 </span></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';
70 * Creates a new Ext.flash.Component instance.
71 * @param {Object} config The component configuration.
74 * @docauthor Jason Johnston <jason@sencha.com>
76 Ext.define('Ext.flash.Component', {
77 extend: 'Ext.Component',
78 alternateClassName: 'Ext.FlashComponent',
79 alias: 'widget.flash',
81 <span id='Ext-flash-Component-cfg-flashVersion'> /**
82 </span> * @cfg {String} flashVersion
83 * Indicates the version the flash content was published for. Defaults to <tt>'9.0.115'</tt>.
85 flashVersion : '9.0.115',
87 <span id='Ext-flash-Component-cfg-backgroundColor'> /**
88 </span> * @cfg {String} backgroundColor
89 * The background color of the SWF movie. Defaults to <tt>'#ffffff'</tt>.
91 backgroundColor: '#ffffff',
93 <span id='Ext-flash-Component-cfg-wmode'> /**
94 </span> * @cfg {String} wmode
95 * The wmode of the flash object. This can be used to control layering. Defaults to <tt>'opaque'</tt>.
96 * Set to 'transparent' to ignore the {@link #backgroundColor} and make the background of the Flash
101 <span id='Ext-flash-Component-cfg-flashVars'> /**
102 </span> * @cfg {Object} flashVars
103 * A set of key value pairs to be passed to the flash object as flash variables. Defaults to <tt>undefined</tt>.
106 <span id='Ext-flash-Component-cfg-flashParams'> /**
107 </span> * @cfg {Object} flashParams
108 * A set of key value pairs to be passed to the flash object as parameters. Possible parameters can be found here:
109 * http://kb2.adobe.com/cps/127/tn_12701.html Defaults to <tt>undefined</tt>.
112 <span id='Ext-flash-Component-cfg-flashAttributes'> /**
113 </span> * @cfg {Object} flashAttributes
114 * A set of key value pairs to be passed to the flash object as attributes. Defaults to <tt>undefined</tt>.
117 <span id='Ext-flash-Component-cfg-url'> /**
118 </span> * @cfg {String} url
119 * The URL of the SWF file to include. Required.
122 <span id='Ext-flash-Component-cfg-swfWidth'> /**
123 </span> * @cfg {String/Number} swfWidth The width of the embedded SWF movie inside the component. Defaults to "100%"
124 * so that the movie matches the width of the component.
128 <span id='Ext-flash-Component-cfg-swfHeight'> /**
129 </span> * @cfg {String/Number} swfHeight The height of the embedded SWF movie inside the component. Defaults to "100%"
130 * so that the movie matches the height of the component.
134 <span id='Ext-flash-Component-cfg-expressInstall'> /**
135 </span> * @cfg {Boolean} expressInstall
136 * True to prompt the user to install flash if not installed. Note that this uses
137 * Ext.FlashComponent.EXPRESS_INSTALL_URL, which should be set to the local resource. Defaults to <tt>false</tt>.
139 expressInstall: false,
141 <span id='Ext-flash-Component-property-swf'> /**
142 </span> * @property swf
143 * @type {Ext.core.Element}
144 * A reference to the object or embed element into which the SWF file is loaded. Only
145 * populated after the component is rendered and the SWF has been successfully embedded.
148 // Have to create a placeholder div with the swfId, which SWFObject will replace with the object/embed element.
149 renderTpl: ['<div id="{swfId}"></div>'],
151 initComponent: function() {
153 if (!('swfobject' in window)) {
154 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/');
157 Ext.Error.raise('The "url" config is required for Ext.flash.Component');
163 <span id='Ext-flash-Component-event-success'> /**
164 </span> * @event success
165 * Fired when the Flash movie has been successfully embedded
166 * @param {Ext.flash.Component} this
170 <span id='Ext-flash-Component-event-failure'> /**
171 </span> * @event failure
172 * Fired when the Flash movie embedding fails
173 * @param {Ext.flash.Component} this
179 onRender: function() {
182 swfId = me.getSwfId();
184 me.renderData.swfId = swfId;
186 me.callParent(arguments);
189 allowScriptAccess: 'always',
190 bgcolor: me.backgroundColor,
195 allowedDomain: document.location.hostname
198 new swfobject.embedSWF(
204 me.expressInstall ? me.statics.EXPRESS_INSTALL_URL : undef,
208 Ext.bind(me.swfCallback, me)
212 <span id='Ext-flash-Component-method-swfCallback'> /**
214 * The callback method for handling an embedding success or failure by SWFObject
215 * @param {Object} e The event object passed by SWFObject - see http://code.google.com/p/swfobject/wiki/api
217 swfCallback: function(e) {
220 me.swf = Ext.get(e.ref);
222 me.fireEvent('success', me);
225 me.fireEvent('failure', me);
229 <span id='Ext-flash-Component-method-getSwfId'> /**
230 </span> * Retrieve the id of the SWF object/embed element
232 getSwfId: function() {
233 return this.swfId || (this.swfId = "extswf" + this.getAutoId());
236 onSuccess: function() {
237 // swfobject forces visiblity:visible on the swf element, which prevents it
238 // from getting hidden when an ancestor is given visibility:hidden.
239 this.swf.setStyle('visibility', 'inherit');
242 onFailure: Ext.emptyFn,
244 beforeDestroy: function() {
248 swfobject.removeSWF(me.getSwfId());
256 <span id='Ext-flash-Component-property-EXPRESS_INSTALL_URL'> /**
257 </span> * Sets the url for installing flash if it doesn't exist. This should be set to a local resource.
258 * See http://www.adobe.com/devnet/flashplayer/articles/express_install.html for details.
262 EXPRESS_INSTALL_URL: 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressInstall.swf'