Highlighted

Can you shorten this code in animate cc (HTML5 canvas ) ?

Explorer ,
Jan 03, 2019

Copy link to clipboard

Copied

B1 is button

snow1 is movie clip

this.B1.addEventListener("click", a1App11.bind(this));

function a1App11() {

this.total++;

this.selection();

}

this.B2.addEventListener("click", a1App2.bind(this));

function a1App2() {

this.total--;

this.selection();

}

var total = 0;
this.total = 0;


this.selection = function () {
if (this.total == 1) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = false;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = false;
  this.front1.snow2.visible = false;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}

if (this.total == 2) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = false;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}

if (this.total == 3) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}

if (this.total == 4) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 5) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 6) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 7) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 8) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 9) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 10) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 11) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = true;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 12) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = true;
  this.front1.snow12.visible = true;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = true;
  this.front1.snow12.visible = false;
}

}

I use canvas html5 >>>

Can you shorten this code ?

When you press the button the snowman (movie clip) shows part part (snow1) ?

TOPICS
Discussions

Views

491

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Can you shorten this code in animate cc (HTML5 canvas ) ?

Explorer ,
Jan 03, 2019

Copy link to clipboard

Copied

B1 is button

snow1 is movie clip

this.B1.addEventListener("click", a1App11.bind(this));

function a1App11() {

this.total++;

this.selection();

}

this.B2.addEventListener("click", a1App2.bind(this));

function a1App2() {

this.total--;

this.selection();

}

var total = 0;
this.total = 0;


this.selection = function () {
if (this.total == 1) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = false;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = false;
  this.front1.snow2.visible = false;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}

if (this.total == 2) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = false;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}

if (this.total == 3) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = false;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}

if (this.total == 4) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = false;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 5) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = false;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 6) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = false;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 7) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = false;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 8) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = false;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 9) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = false;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 10) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = false;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 11) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = true;
  this.front1.snow12.visible = false;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = false;
  this.front1.snow12.visible = false;
}
if (this.total == 12) {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = true;
  this.front1.snow12.visible = true;
} else {
  this.front1.snow1.visible = true;
  this.front1.snow2.visible = true;
  this.front1.snow3.visible = true;
  this.front1.snow4.visible = true;
  this.front1.snow5.visible = true;
  this.front1.snow6.visible = true;
  this.front1.snow7.visible = true;
  this.front1.snow8.visible = true;
  this.front1.snow9.visible = true;
  this.front1.snow10.visible = true;
  this.front1.snow11.visible = true;
  this.front1.snow12.visible = false;
}

}

I use canvas html5 >>>

Can you shorten this code ?

When you press the button the snowman (movie clip) shows part part (snow1) ?

TOPICS
Discussions

Views

492

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 03, 2019 0
Adobe Community Professional ,
Jan 03, 2019

Copy link to clipboard

Copied

Hi.

You want only one snow to be visible at a time, right?

If so, you can write this:

var current = 0;

function selectSnow(e)

{

    var children = this.front1.children;

    if (e.currentTarget === this.b1)

          current = Math.max(--current, 0);

    else if (e.currentTarget === this.b2)

          current = Math.min(++current, children.length - 1);

    children.forEach(function(snow, index)

    {

         snow.visible = index !== current ? false : true;

    });

}

this.b1.on("click", selectSnow, this);

this.b2.on("click", selectSnow, this);

FLA download:

animate_cc_html5_canvas_shorten_code.zip - Google Drive

But I bet someone else will suggest an even shorter code!

I hope this helps.

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 03, 2019 3
Explorer ,
Jan 05, 2019

Copy link to clipboard

Copied

JoãoCésar 

You want only one snow to be visible at a time, right?

no

I want to show the snowman by order

And when the error disappears part of it

Attached is a sample

https://drive.google.com/file/d/1iwVg0zO7J-yJJ3ei4BiaZqHB-8kERhBy/view?usp=sharing

Thanks for your cooperation

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 05, 2019 0
Adobe Community Professional ,
Jan 06, 2019

Copy link to clipboard

Copied

JC, we're all impressed by how cryptically you can solve people's problems, but it's not exactly beginner-friendly code, is it?

تقنية المعلومات, just replace your selection function with this:

this.selection = function() {

    for (var i = 1; i < 13; i++) {

        this.front1["snow" + i].visible = (i >= this.total);

    }

}

Not tested, but should work, or be close enough that you can figure it out.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 06, 2019 2
Explorer ,
Jan 06, 2019

Copy link to clipboard

Copied

Try it .. The code does not work .. I do not know why??

https://drive.google.com/file/d/1iwVg0zO7J-yJJ3ei4BiaZqHB-8kERhBy/view?usp=sharing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 06, 2019 0
Adobe Community Professional ,
Jan 07, 2019

Copy link to clipboard

Copied

Nothing about that document works, and my code isn't even in it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 07, 2019 0
Explorer ,
Jan 08, 2019

Copy link to clipboard

Copied

animate_cc_html5_canvas_shorten_code33.fla - Google Drive

Corrected again

Works if you delete the code

I hope you help me

Thank you so much

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2019 0
Adobe Community Professional ,
Jan 08, 2019

Copy link to clipboard

Copied

This version just asks math problems forever. It never runs the code you're trying to shorten. I have no idea what you expect anyone to do with this.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2019 0
Explorer ,
Jan 09, 2019

Copy link to clipboard

Copied

thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 09, 2019 0
Explorer ,
Jan 26, 2019

Copy link to clipboard

Copied

JoãoCésar's answer incorrect ?

Preran

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 26, 2019 0
Preran LATEST
Adobe Employee ,
Jan 28, 2019

Copy link to clipboard

Copied

Thank you for letting me know. As the original poster, you have the permissions to unmark my decisions yourself. In this case, I have done it for you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 28, 2019 0