• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

(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

228

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
Community Expert ,
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.

Votes

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

 

Votes

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
Community Expert ,
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).

Votes

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

 

 

Votes

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
Community Expert ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

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