Ext JS-extjs 中怎么加载 swf

Ext JS-extjs 中怎么加载 swf

虐人心 发布于 2017-02-22 字数 28 浏览 1235 回复 2

extjs 中怎么加载 swf?

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瑾兮 2017-10-08 2 楼

可以使用 Ext.FlashComponent 这个类,(extjs 3.0 新增)该类继承了 Ext.BoxComponent。

该类的配置以及方法太多了就不往出贴了。 用法以及详细配置可以到 http://docs.sencha.com/ext-js/4-0/#!/api/Ext.flash.Component
发现源码也不是很长,贴出来看一下

/**
* @class Ext.FlashComponent
* @extends Ext.BoxComponent
* @constructor
* @xtype flash
*/
Ext.FlashComponent = Ext.extend(Ext.BoxComponent, {
/**
* @cfg {String} flashVersion
* Indicates the version the flash content was published for. Defaults to '9.0.45'.
*/
flashVersion : '9.0.45',

/**
* @cfg {String} backgroundColor
* The background color of the chart. Defaults to '#ffffff'.
*/
backgroundColor: '#ffffff',

/**
* @cfg {String} wmode
* The wmode of the flash object. This can be used to control layering. Defaults to 'opaque'.
*/
wmode: 'opaque',

/**
* @cfg {String} url
* The URL of the chart to include. Defaults to undefined.
*/
url: undefined,
swfId : undefined,
swfWidth: '100%',
swfHeight: '100%',

/**
* @cfg {Boolean} expressInstall
* True to prompt the user to install flash if not installed. Note that this uses
* Ext.FlashComponent.EXPRESS_INSTALL_URL, which should be set to the local resource. Defaults to false.
*/
expressInstall: false,

initComponent : function(){
Ext.FlashComponent.superclass.initComponent.call(this);

this.addEvents('initialize');
},

onRender : function(){
Ext.FlashComponent.superclass.onRender.apply(this, arguments);

var params = {
allowScriptAccess: 'always',
bgcolor: this.backgroundColor,
wmode: this.wmode
}, vars = {
allowedDomain: document.location.hostname,
elementID: this.getId(),
eventHandler: 'Ext.FlashEventProxy.onEvent'
};

new swfobject.embedSWF(this.url, this.id, this.swfWidth, this.swfHeight, this.flashVersion,
this.expressInstall ? Ext.FlashComponent.EXPRESS_INSTALL_URL : undefined, vars, params);

this.swf = Ext.getDom(this.id);
this.el = Ext.get(this.swf);
},

getSwfId : function(){
return this.swfId || (this.swfId = "extswf" + (++Ext.Component.AUTO_ID));
},

getId : function(){
return this.id || (this.id = "extflashcmp" + (++Ext.Component.AUTO_ID));
},

onFlashEvent : function(e){
switch(e.type){
case "swfReady":
this.initSwf();
return;
case "log":
return;
}
e.component = this;
this.fireEvent(e.type.toLowerCase().replace(/event$/, ''), e);
},

initSwf : function(){
this.onSwfReady(!!this.isInitialized);
this.isInitialized = true;
this.fireEvent('initialize', this);
},

beforeDestroy: function(){
if(this.rendered){
swfobject.removeSWF(this.swf.id);
}
Ext.FlashComponent.superclass.beforeDestroy.call(this);
},

onSwfReady : Ext.emptyFn
});

/**
* Sets the url for installing flash if it doesn't exist. This should be set to a local resource.
* @static
* @type String
*/
Ext.FlashComponent.EXPRESS_INSTALL_URL = 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressInstall.swf';

Ext.reg('flash', Ext.FlashComponent);

夜无邪 2017-06-26 1 楼

加载swf还是用SWFObject