Skip to main content
Participant
August 4, 2020
Question

convert flash to html5, global variable problem

  • August 4, 2020
  • 2 replies
  • 471 views

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 :

this.BtnSuiv.addEventListener("click", fl_ClickToGoToAndPlayFromFrame.bind(this));
        
            function fl_ClickToGoToAndPlayFromFrame() {
                this.gotoAndPlay(15);
            }
But i still have an error on the rest of the build, especially for launching an audio in files. The code gCh.script_mc.gestionSon (Code + "01b.mp3"); does not work, because the gCh. is not defined, just like the _global of the other variables below. Do you know what to replace global variable in JS and HTML canevas, and how I could run an audio with correct code.
 

// 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 !

This topic has been closed for replies.

2 replies

Participant
August 4, 2020

in Canvas you should use 'stage' instead of global
_global.varName    ==> stage.varName

and "exportRoot" instead of "_root"

Legend
August 4, 2020

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.

Participant
August 4, 2020

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);
}