This code below is obsolete.
It's usefull to prevent RequireJS to handle external plugins loaded via AJAX.
It's related to anonymous module problem: http://requirejs.org/docs/errors.html#mismatch
Code: Select all
Macro DisableRequireJS
!window.old_requirejs_define = window.define
!window.define=false
EndMacro
Macro EnableRequireJS
!window.define = window.old_requirejs_define
EndMacro
CompilerIf #PB_Compiler_IsMainFile
; ******************
; EXAMPLE
; ******************
Procedure.i LoadAsynchronously(FileName.s, *OnLoadFunction, FileType.s)
!return $.ajax({ url:v_FileName, dataType:v_FileType, beforeSend:function(jqxhr, settings) { jqxhr.url = settings.url; } })
!.done(function(data, status, jqxhr) { p_OnLoadFunction(data,status,jqxhr.url); })
!.fail(function(jqxhr, status, errorThrown) { p_OnLoadFunction('',status,jqxhr.url,jqxhr.status,errorThrown); })
EndProcedure
Procedure.i LoadScript(FileName.s, *OnLoadFunction)
ProcedureReturn LoadAsynchronously(FileName, *OnLoadFunction, "script")
EndProcedure
Procedure ScriptLoaded(script.s, status.s, jqxhr)
If status<>"success" : ProcedureReturn : EndIf
EnableRequireJS ;// enable requireJS
Protected IsPIXIPluginReady
!v_IsPIXIPluginReady = PIXI ? 1:0;
If IsPIXIPluginReady
!alert("Plugin Ready")
Debug "Plugin Ready"
EndIf
EndProcedure
DisableRequireJS ;// disable temporarily requireJS
LoadScript("https://raw.githubusercontent.com/GoodBoyDigital/pixi.js/dev/bin/pixi.js",@ScriptLoaded())
CompilerEndIf