convert flash to html5, global variable problem
Copy link to clipboard
Copied
Hi,
i'm trying to convert files in Flash to HTML5 Canevas.
My current problem is the global variables being generated, they cause an error. _Global is not defined.
To start I already modify the code to change images with button, passing from that:
BtnSuiv.onRelease = function() {
_global.Exo.gotoAndPlay("Explication02");
};
to that :
// Globale pour situer le niveau de l'étape
_global.Exo = this;
// Globale qui enlève le clignotement de la fleche "étape suivante"
gInterface.finEtape(0);
// Globale qui initialise les bulles de la mascotte
_global.BulleRepExo = 0;
//Attitude de la mascotte
gInterface.FCTmascotte("Explication01");
//Gestion du son
gCh.script_mc.gestionSon("H0104_01_01a.mp3");
Thanks in advance for your help !
Copy link to clipboard
Copied
edit :
I found a script file in my folders. This file defines the global variables. My current problem is to call it in my files. The conversion gives me this code to make the link between my current file and the script that defines the variables, but the loadMovie code seems obsolete :
_global.gCh = this;
if (_global.rNavigation == undefined) {
if (this._parent == undefined) {
//joué en mode auteur dans cette étape
loadMovie("../scripts.js", script_mc);
} else {
//joué en mode auteur dans interface.fla
loadMovie("scripts.js", script_mc);
}
} else {
//joué dans le navigateur
loadMovie("asset/scripts.js", script_mc);
}
Copy link to clipboard
Copied
in Canvas you should use 'stage' instead of global
_global.varName ==> stage.varName
and "exportRoot" instead of "_root"
Copy link to clipboard
Copied
You can use either exportRoot or stage for storage. They're both global objects that you can stuff anything into it. But it might actually be easier for him to port existing code by just creating a new global object named _global. Just add this somewhere in the initialization code:
window._global = {};
Voila, AS2-like global storage.
Copy link to clipboard
Copied
hey,
I neglected to tell you that the file I was passing from action script to html canvas was already obsolete. It's content in action script 2 that is transcribed in action script 3 in adobe animate.
This leads me to believe that I have to completely change my method of handling these variables. After a thorough analysis of every important file, I can't find any functions, objects that define global variables, gCh etc, which are followed by information like sound or mascot and are supposed to return content like sound or images to specific folders.
I didn't understand the terms "exportRoot" and "stage" for storage.

