(hrml5,ANCC,JS)(Splicing name;Array;method)The error is known, but it will not be modified.

Enthusiast ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

Use alone “alert”,It can be run.

If  use "on click", an error occurs.

Browser console.log "Uncaught SyntaxError: missing ) after argument list"

It should be an error caused by the name in "for"

But i don't know how to solve

 

 

var map1 = [{id:11}, {id:12}, {id:13},{id:14}, {id:15}, {id:16},{id:17}, {id:18}, {id:19}],jswz = 0
Object.prototype.myUcase = function() {
alert("map1" + this.id) //It can be run
this.on("click", function() {alert("map" + this.id)} ;//error, Unable to run
}
for(i = 0; i < map1.length; i++) {
//asa0 to asa8,This is a movie-clip on stage
exportRoot["asa" + i].id=map1[i].id
exportRoot["asa" + i]=map1[i]
exportRoot["asa" + i].myUcase()//Error,
}

Views

119

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
community guidelines
Adobe Community Professional ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

you didn't close your "on" method and you have an extraneous right bracket.  ie, you're missing a right paranthesis at the end of your shown code and you have mismatched brackets.

 

other than that, i can't determine what that's supposed to do even if it were syntactically correct.

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
community guidelines
Enthusiast ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

 

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
community guidelines
Adobe Community Professional ,
Jan 21, 2021 Jan 21, 2021

Copy link to clipboard

Copied

i'm not sure what you mean by that, but

 

map1 is properly defined without syntax error while dt has a syntax error (comma after last element).

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
community guidelines
Enthusiast ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

Thank you very much for your answer

I found the cause of the problem.

exportRoot["asa" + i]=map1[i]

It is equivalent to replacing the movie clip with array elements.

This operation is not feasible.

Needs to be modified to:

map1[i]=exportRoot["asa" + i]

Replace array elements with movie clips.

Code can now be executed normally

 

 

 

var map1 = [{id:11}, {id:12}, {id:13},{id:14}, {id:15}, {id:16},{id:17}, {id:18},{id:19}],jswz = 0;
Object.prototype.myUcase = function() {
alert("map1" + this.id) 
this.on("click", function() {alert("map" + this.id)})
}
for(i = 0; i < map1.length; i++) {
//asa0 to asa8,This is a movie-clip on stage
exportRoot["asa" + i].id=map1[i].id
map1[i]=exportRoot["asa" + i]
exportRoot["asa" + i].myUcase();
}

 

 

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
community guidelines
Adobe Community Professional ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

LATEST

you're welcome.

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
community guidelines