Flash

window.SWFready=$.Deferred(); // Deferred makes sure we don’t call ASSetEditMode before SWF is ready.
function JSeditorReady() {
console.log(‘swfReady’);
try {
SWFready.resolve();
return true;
} catch (error) {
console.error(error.message, “\n”, error.stack);
throw error;
}
}

function handleEmbedStatus(e) {
$(‘#scratch-loader’).hide();
if(!e.success) {
$(‘#scratch’).css(‘marginTop’, ’10’);
$(‘#scratch IMG.proj_thumb’).css(‘width’, ‘179px’);
$(‘#scratch DIV.scratch_unsupported’).show();
$(‘#scratch DIV.scratch_loading’).hide();
}else{
$(‘#scratch’).css(‘visibility’, ‘visible’);
}
}

// The flashvars tell flash about the project data (and autostart=true)
var flashvars = {
autostart: ‘false’,
server: encodeURIComponent(location.host),
cloudToken: ‘00000000-0000-0000-0000-000000000000’,
cdnToken: ‘3a6b24c7f17a7e72ff07f09ceb7e29b7’,
urlOverrides: {
sitePrefix: “http://scratch.mit.edu/”,
siteCdnPrefix: “http://cdn.scratch.mit.edu/”,
assetPrefix: “http://assets.scratch.mit.edu/”,
assetCdnPrefix: “http://cdn.assets.scratch.mit.edu/”,
projectPrefix: “http://projects.scratch.mit.edu/”,
projectCdnPrefix: “http://cdn.projects.scratch.mit.edu/”,
internalAPI: “internalapi/”,
siteAPI: “site-api/”,
staticFiles: “scratchr2/static/”
},

inIE: (navigator.userAgent.indexOf(‘MSIE’) > -1)
};

$.each(flashvars, function(prop, val) {
if($.isPlainObject(val))
flashvars[prop] = encodeURIComponent(JSON.stringify(val));
});

$.each(Scratch.INIT_DATA.PROJECT.model, function(i, val) {
if(val != null)
flashvars[‘project_’+i] = encodeURIComponent(val);
});

if(Scratch.INIT_DATA.PROJECT.is_new)
flashvars.project_isNew = true;

var params = {
allowscriptaccess: ‘always’,
allowfullscreen: ‘true’,
wmode: ‘direct’,
menu: ‘false’};

var swfFile = (swfobject.hasFlashPlayerVersion(‘11.7.0’) ? ‘Scratch.swf’ : ‘ScratchFor10.2.swf’);

swfobject.embedSWF(“//cdn.scratch.mit.edu/scratchr2/static/__3a6b24c7f17a7e72ff07f09ceb7e29b7__/” + swfFile, “scratch”, “100%”, “100%”, “10.2.0”,
“//cdn.scratch.mit.edu/scratchr2/static/__3a6b24c7f17a7e72ff07f09ceb7e29b7__/expressInstall.swf”, flashvars, params, null, handleEmbedStatus);

//Dynamically add iframe for registration window
$.when(window.SWFready).done(function() {$(‘<iframe id=”registration-iframe” class=”iframeshim” style=”background:#fff;z-index:-1;” frameborder=”0″ scrolling=”no”>’).insertBefore(‘#registration’)});

// enables the SWF to log errors
function JSthrowError(e) {
if (window.onerror) window.onerror(e, ‘swf’, 0);
else console.error(e);
}

Archívum