Hi, gurus and JS superheroes! I'm a newbie in scripting and coding, so sorry for my mistakes and possibly wrong definitions. I hope you will understand what the problem is there. I'm trying to make a 2 slider calculator with 2 bonus calculation options. The basics is NumSlider1 * NumSlider2 * Multiplier(Option 1 or 2). I started with a script that I found here in the forum created by some genius @JoãoCésar. I duplicated the first slider and made a first level calculations to live - sliders now multiplying. That's fine. Then I created "checkboxes" and found the way how to click them to and back. Here is where I stuck. I can't force my "checkbox" to add and change the number in the variable. The goal is to Add a bigger number to the "multiplier" by clicking on Option 2. Here are the resources - Fla. (I hope it will go through customs here) https://drive.google.com/drive/folders/12ESJ89wR16sJtmk3PkTXnakOj727nuKe?usp=sharing And here is all the code actually. Maybe somebody can tell from here what's actually wrong. The VAR MULTI is my poor and sick variable, I try to force to change with my event listeners for checkboxes. var multi = 12;
/* this stops movie to display checkmark checked in "Option1" as page loads */
this.check_square_n.gotoAndStop(24);
/*This are 2 event listeners and commands to play and stop both checkmark movies keeping ability to check & recheck back*/
this.check_square_n.addEventListener("click", fl_MouseClickHandler1.bind(this));
function fl_MouseClickHandler1()
{
this.check_square_n.gotoAndPlay(2);
this.check_square_y.gotoAndStop(1);
/* this.multi = 12; */
}
this.check_square_y.addEventListener("click", fl_MouseClickHandler2.bind(this));
function fl_MouseClickHandler2()
{
this.check_square_y.gotoAndPlay(2);
this.check_square_n.gotoAndStop(1);
/* this.multi = 22; */
}
/*--------------------------- This all two sliders and calculations --------------------------*/
this.button1.on("mousedown", function (e) {
e.target.offsetX = (e.stageX / stage.scaleX) - e.target.x;
}.bind(this));
this.button1.on("pressmove", function (e) {
e.target.x = this.clamp1((e.stageX / stage.scaleX) - e.target.offsetX, this.bar1.x, this.bar1.x + this.bar1.nominalBounds.width);
this.setProportion();
}.bind(this));
this.button2.on("mousedown", function (e) {
e.target.offsetX = (e.stageX / stage.scaleX) - e.target.x;
}.bind(this));
this.button2.on("pressmove", function (e) {
e.target.x = this.clamp2((e.stageX / stage.scaleX) - e.target.offsetX, this.bar2.x, this.bar2.x + this.bar2.nominalBounds.width);
this.setProportion();
}.bind(this));
this.setProportion = function () {
var prop1 = (this.button1.x - this.bar1.x) / this.bar1.nominalBounds.width;
var prop2 = (this.button2.x - this.bar2.x) / this.bar2.nominalBounds.width;
var euro = Math.round(prop1 * 100);
var year = Math.round(Math.round(prop2 * 100) * 0.3);
/*These are displayed numbers linked to sliders*/
this.txt1.text = euro;
this.txt2.text = year;
/* These 2 rows are for design only, to reveal color in slider left sides*/
this.bar1.gotoAndStop(Math.floor(this.bar1.timeline.duration * prop1));
this.bar2.gotoAndStop(Math.floor(this.bar2.timeline.duration * prop2));
/* ------------------- This calculates the sum --------------
!!! And this is the place where I would like to use "multi" as variable number defined by clicking on one or another "Option" -------- */
this.calc.text = euro*year*multi;
/*This is for my visual control only. Will be removed from screen*/
this.multiX.text = multi;
}.bind(this);
/*---------- This defines range of sliders ------ */
this.clamp1 = function (value, min, max) {
if (value < min)
return min +4;
else if (value > max)
return max;
else
return value;
}
this.clamp2 = function (value, min, max) {
if (value < min)
return min + 8;
else if (value > max)
return max;
else
return value;
}
/* --------- This sets numbers and sliders displayed on first load -------- */
setTimeout(this.setProportion, 0);
/*-------- THE END OF THE MAGIC -------*/ Thanks in advance!
... View more