I have a Flash file that I'm converting to HTML5 with CreateJS. The Flash file is fairly complex (for an MPU banner, at least) with lots of GSAP timelines and other functions. I've converted most of the specific functions (eg, performing a certain animation after a delayed call from TimelineMax), however I'm stuck on one thing:
In the Flash file I've got a group of about 20 instances of a MovieClip ("Pulsar"). On the Pulsar MC there is a frame script with a few simple functions, for example "pulse", which listens for a global boolean "killPulses" being false, and then randomly pulses (by running along the MC's timeline), until such time as "killPulses" is true.
function pulse(time:Number = 1.5):void {
if (isPulsing == false) {
isPulsing = true;
TweenLite.to(this, time, {frameLabel:"pulse_end", onComplete:resetPulse});
}
}
function resetPulse():void {
gotoAndStop("pulse_start");
isPulsing = false;
}
function callRandomPulse(e:Event):void {
var ran = Math.random();
if (MovieClip(root).killPulses == true) {
freqNumber = 0;
} else {
freqNumber = defaultFreq;
}
if (ran < freqNumber) {
pulse();
}
}
TweenLite.ticker.addEventListener("tick", callRandomPulse);
This was fairly easy in Flash, but as script isn't ported in CreateJS, how do I add these functions to the lib.Pulsar object in JS? I would rather do it outside the main .js file, as otherwise it would get overwritten each time I re-export. I can't seem to access the internal properties of lib.Pulsar (a console log just gives me the function script, rather than its properties?). Is that the best way to add the functions or is there a more suitable way?
The intended effect is that the group of Pulsars pulse randomly and out of sync with each other, but only while they're 'activated'.
Thanks!