Trigger Events from Flash to an UI-Widget
How can I trigger an event from an embeded flash to a jQuery-UI Widget?.
I've written an uploader and now I ant to write a UI-Plugin / Wiget.
- (function($) {
$.widget('ui.uploader', {
// Options
options: {
},
_create: function() {
var obj = this.element, self = this;
var opts = self.options,
lang = self.locale,
idx = $.ui.uploader.getId(obj),
idUpload = (self.idUpload = idx + 'SWF'),
idUploadBody = (self.idUploadBody = idx + 'Body'),
idUploadPanel = (self.idUploadPanel = idx + 'Panel'),
idUploadBrowse = (self.idUploadBrowse = idx + 'Browse'),
idUploadFlash = (self.idUploadFlash = idx + 'Flash'),
idUploadStart = (self.idUploadStart = idx + 'Start'),
idUploadStop = (self.idUploadStop = idx + 'Stop'),
idUploadQueue = (self.idUploadQueue = (opts.queueID ? opts.queueID : idx + 'Queue'));
if (!opts.fdata) {
opts.fdata = (obj.attr('name') ? obj.attr('name') : 'filedata');
}
// ...
swfobject.embedSWF(
opts.swfuploader, self.idUpload, data.width, data.height, '9.0.24', opts.swfinstaller,
data, {
'allowScriptAccess' : ( !(typeof(opts.swfaccess) == 'undefined' && opts.swfaccess == 'always') ? 'sameDoamin' : 'always'),
'quality': 'high', 'wmode': 'transparent'
}
);
$('#' + data.swfid).hover(
function() { $('#' + self.idUploadBrowse).removeClass('ui-state-default').addClass('ui-state-hover'); },
function() { $('#' + self.idUploadBrowse).removeClass('ui-state-hover').addClass('ui-state-default'); }
).focus(function() {
$('#' + self.idUploadBrowse).removeClass('ui-state-default').removeClass('ui-state-hover').addClass('ui-state-focus');
}).blur(function() {
$('#' + self.idUploadBrowse).removeClass('ui-state-focus').removeClass('ui-state-hover').addClass('ui-state-default');
}).bind('select.uploader', { 'action': opts.onSelect }, function(evt, idx, file, data, fast) {
if (evt.data.action(evt, idx, file, data, false) !== false) {
alert('File-ID is: ' + idx);
}
});
// ....
}
});
$.extend($.ui.uploader, {
version: "@VERSION",
uuid: 0,
maxZ: 0,
getId: function($el) {
var id = $el.attr('id');
var name = $el.attr('name');
if (!name) {
name = 'ui-uploader';
}
if (!id) {
this.uuid += 1;
id = name + this.uuid;
}
return id;
},
});
}(jQuery));
How can I trigger the Event $('#' + swfID).trigger('select.uploader, {...} , function (event, ID, fileObj, ...) {...}
from Flash or other Widgets?
Many thanks for quick reply ;)